Skip to content

Commit

Permalink
Deprecate public methods for removed collection size feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Johnson committed Jan 24, 2020
1 parent 84b4016 commit 2b2b9c5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/concerns/hyrax/collection_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ def collection_type_gid_document_field_name
end
end

# @deprecated to be removed in 4.0.0; this feature was replaced with a
# hard-coded null implementation
# @return [Fixnum] 0
def bytes
Deprecation.warn("#bytes has been deprecated for removal in Hyrax 4.0.0; " \
"The implementation of the indexed Collection size " \
"feature extremely inefficient, so it has been removed. " \
"This method now returns a hard-coded `0` for compatibility.")
0
end

# @api public
# Retrieve the permission template for this collection.
# @return [Hyrax::PermissionTemplate]
Expand Down
17 changes: 17 additions & 0 deletions app/presenters/hyrax/collection_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,32 @@ def terms_with_values
self.class.terms.select { |t| self[t].present? }
end

##
# @param [Symbol] key
# @return [Object]
def [](key)
case key
when size
size
when :total_items
total_items
else
solr_document.send key
end
end

# @deprecated to be removed in 4.0.0; this feature was replaced with a
# hard-coded null implementation
# @return [String] 'unknown'
def size
Deprecation.warn("#size has been deprecated for removal in Hyrax 4.0.0; " \
"The implementation of the indexed Collection size " \
"feature extremely inefficient, so it has been removed. " \
"This method now returns a hard-coded `\"unknown\"` for " \
"compatibility.")
'unknown'
end

def total_items
ActiveFedora::Base.where("member_of_collection_ids_ssim:#{id}").count
end
Expand Down

0 comments on commit 2b2b9c5

Please sign in to comment.