Skip to content

Commit

Permalink
Merge pull request #418 from IU-Libraries-Joint-Development/essi-1595…
Browse files Browse the repository at this point in the history
…_collection_count_post

[ESSI-1595] use POST in collection descendant counts
  • Loading branch information
aploshay authored Apr 8, 2022
2 parents e002756 + 1952353 commit ed0b14b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/models/concerns/essi/collection_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ def self.included(base)
end

module ClassMethods
# solr queries break if you pass an id set with greater than 96 members
def constrain_ids(ids)
Array.wrap(ids)[0,96]
end

# POST to avoid URI Too Long error from solr, and raise row limit
def child_objects_for(id, models: [])
id = constrain_ids(id)
id = Array.wrap(id)
return [] if id.empty?
conditions = { nesting_collection__parent_ids_ssim: id }
models = Array.wrap(models).map(&:to_s)
conditions[:has_model_ssim] = models if models.any?
ActiveFedora::Base.search_with_conditions(conditions, rows: 100_000)
options = { method: :post, rows: 100_000 }
ActiveFedora::Base.search_with_conditions(conditions, options)
end

def child_collections_for(id)
Expand Down

0 comments on commit ed0b14b

Please sign in to comment.