From 84377b97092460b931decac91fd675e5a7ebed61 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Thu, 30 May 2024 14:10:58 -0700 Subject: [PATCH] :bug: Correct thumbnail_path_ss value --- app/forms/hyrax/forms/pcdm_collection_form_decorator.rb | 2 +- app/indexers/collection_resource_indexer.rb | 1 + app/services/hyrax/indexes_thumbnails_decorator.rb | 3 ++- ...migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb b/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb index ee5e377533..a239b7b879 100644 --- a/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb +++ b/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb @@ -12,7 +12,7 @@ if thumbnail_info thumbnail_file = File.split(thumbnail_info.local_path).last alttext = thumbnail_info.alt_text - file_location = thumbnail_info.local_path + file_location = thumbnail_info.local_path.gsub('/app/samvera', '') relative_path = "/" + thumbnail_info.local_path.split("/")[-4..-1].join("/") { file: thumbnail_file, full_path: file_location, relative_path:, alttext: } else diff --git a/app/indexers/collection_resource_indexer.rb b/app/indexers/collection_resource_indexer.rb index fe2113e259..c5af47560c 100644 --- a/app/indexers/collection_resource_indexer.rb +++ b/app/indexers/collection_resource_indexer.rb @@ -6,6 +6,7 @@ class CollectionResourceIndexer < Hyrax::Indexers::PcdmCollectionIndexer include Hyrax::Indexer(:basic_metadata) include Hyrax::Indexer(:bulkrax_metadata) include Hyrax::Indexer(:collection_resource) + include Hyrax::IndexesThumbnails def to_solr super.tap do |index_document| diff --git a/app/services/hyrax/indexes_thumbnails_decorator.rb b/app/services/hyrax/indexes_thumbnails_decorator.rb index 6620d5f979..d639830483 100644 --- a/app/services/hyrax/indexes_thumbnails_decorator.rb +++ b/app/services/hyrax/indexes_thumbnails_decorator.rb @@ -6,10 +6,11 @@ module Hyrax module IndexesThumbnailsDecorator # Returns the value for the thumbnail path to put into the solr document def thumbnail_path + object ||= @object || resource if object.try(:collection?) && UploadedCollectionThumbnailPathService.uploaded_thumbnail?(object) UploadedCollectionThumbnailPathService.call(object) else - super + CollectionResourceIndexer.thumbnail_path_service.call(object).gsub('/app/samvera', '') end end end diff --git a/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake b/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake index de8a4cd56a..05e0a0b641 100644 --- a/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake +++ b/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake @@ -7,7 +7,7 @@ namespace :hyku do Collection.find_each do |collection| # get collection solr document's thumbnail_path for each collection doc = collection.to_solr - original_thumbnail_path = File.join(Rails.public_path, doc['thumbnail_path_ss']) + original_thumbnail_path = File.join('public/branding/', doc['thumbnail_path_ss']) next unless File.exist?(original_thumbnail_path)