app/indexers/hyrax/valkyrie_work_indexer.rb in hyrax-4.0.0.beta1 vs app/indexers/hyrax/valkyrie_work_indexer.rb in hyrax-4.0.0.beta2

- old
+ new

@@ -23,10 +23,12 @@ solr_doc['member_ids_ssim'] = resource.member_ids.map(&:to_s) solr_doc['depositor_ssim'] = [resource.depositor] solr_doc['depositor_tesim'] = [resource.depositor] solr_doc['hasRelatedMediaFragment_ssim'] = [resource.representative_id.to_s] solr_doc['hasRelatedImage_ssim'] = [resource.thumbnail_id.to_s] + index_embargo(solr_doc) + index_lease(solr_doc) end end private @@ -36,8 +38,27 @@ def admin_set_label(resource) return if resource.admin_set_id.blank? admin_set = Hyrax.query_service.find_by(id: resource.admin_set_id) admin_set.title + end + + def index_embargo(doc) + if Hyrax::EmbargoManager.new(resource: resource).under_embargo? + doc['embargo_release_date_dtsi'] = resource.embargo.embargo_release_date&.to_datetime + doc['visibility_after_embargo_ssim'] = resource.embargo.visibility_after_embargo + doc['visibility_during_embargo_ssim'] = resource.embargo.visibility_during_embargo + end + doc + end + + def index_lease(doc) + if Hyrax::LeaseManager.new(resource: resource).under_lease? + doc['lease_expiration_date_dtsi'] = resource.lease.lease_expiration_date&.to_datetime + doc['visibility_after_lease_ssim'] = resource.lease.visibility_after_lease + doc['visibility_during_lease_ssim'] = resource.lease.visibility_during_lease + end + + doc end end end