Skip to content

Commit

Permalink
Use uncached only on the ActiveFedora find
Browse files Browse the repository at this point in the history
  • Loading branch information
LaRita Robinson authored and elrayle committed Oct 11, 2017
1 parent adc7d02 commit ebea606
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions .rubocop_fixme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Metrics/ModuleLength:
- 'app/models/concerns/hyrax/ability.rb'
- 'app/services/hyrax/workflow/permission_query.rb'
- 'spec/services/hyrax/workflow/permission_query_spec.rb'
# TODO: extract CollectionAccessControls or something, so we don't have to skip this check?
- 'app/models/concerns/hyrax/collection_behavior.rb'

Metrics/MethodLength:
Expand Down
30 changes: 15 additions & 15 deletions app/services/hyrax/adapters/nesting_index_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def self.find_preservation_document_by(id:)
def self.find_preservation_parent_ids_for(id:)
# Not everything is guaranteed to have library_collection_ids
# If it doesn't have it, what do we do?
ActiveFedora::Base.uncached do
fedora_object = ActiveFedora::Base.uncached do
fedora_object = ActiveFedora::Base.find(id)
end

if fedora_object.respond_to?(:member_of_collection_ids)
fedora_object.member_of_collection_ids
else
[]
end
if fedora_object.respond_to?(:member_of_collection_ids)
fedora_object.member_of_collection_ids
else
[]
end
end

Expand Down Expand Up @@ -68,16 +68,16 @@ def self.each_perservation_document_id_and_parent_ids(&block)
# @param pathnames [Array<String>]
# @return Hash - the attributes written to the indexing layer
def self.write_document_attributes_to_index_layer(id:, parent_ids:, ancestors:, pathnames:)
ActiveFedora::Base.uncached do
solr_doc = ActiveFedora::Base.find(id).to_solr # What is the current state of the solr document

# Now add the details from the nesting indexor to the document
solr_doc[solr_field_name_for_storing_ancestors] = ancestors
solr_doc[solr_field_name_for_storing_parent_ids] = parent_ids
solr_doc[solr_field_name_for_storing_pathnames] = pathnames
ActiveFedora::SolrService.add(solr_doc, commit: true)
solr_doc
solr_doc = ActiveFedora::Base.uncached do
ActiveFedora::Base.find(id).to_solr # What is the current state of the solr document
end

# Now add the details from the nesting indexor to the document
solr_doc[solr_field_name_for_storing_ancestors] = ancestors
solr_doc[solr_field_name_for_storing_parent_ids] = parent_ids
solr_doc[solr_field_name_for_storing_pathnames] = pathnames
ActiveFedora::SolrService.add(solr_doc, commit: true)
solr_doc
end

# @api public
Expand Down

0 comments on commit ebea606

Please sign in to comment.