Skip to content
This repository has been archived by the owner on Nov 26, 2019. It is now read-only.

Avoid calling representative_presenter for each child work on a parent show page #731

Merged
merged 1 commit into from Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/indexers/chf/generic_work_indexer.rb
Expand Up @@ -28,6 +28,13 @@ def generate_solr_document
# If the thing isn't found in the license service, just ignore it.
license_service.authority.find(id).fetch('term', nil)
end.compact

if object.representative_id && object.representative
# need to index these for when it's a child work on a parent's show page
doc[ActiveFedora.index_field_mapper.solr_name('representative_width', type: :integer)] = object.representative.width.first if object.representative.width.present?
doc[ActiveFedora.index_field_mapper.solr_name('representative_height', type: :integer)] = object.representative.height.first if object.representative.height.present?
doc[ActiveFedora.index_field_mapper.solr_name('representative_original_file_id')] = object.representative.original_file.id if object.representative.original_file
end
end
end

Expand Down
Expand Up @@ -81,18 +81,15 @@ def show_thumb_member_presenters
end

def riiif_file_id
return if representative_presenter.nil?
representative_presenter.riiif_file_id
solr_document[ActiveFedora.index_field_mapper.solr_name('representative_original_file_id')]
end

def representative_height
return if representative_presenter.nil?
representative_presenter.height
solr_document[ActiveFedora.index_field_mapper.solr_name('representative_height', type: :integer)]
end

def representative_width
return if representative_presenter.nil?
representative_presenter.width
solr_document[ActiveFedora.index_field_mapper.solr_name('representative_width', type: :integer)]
end
end
end