From 69dbe27e95e81f2da02ec6d9950d674f47ee1cac Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 1 Nov 2024 11:43:24 -0400 Subject: [PATCH 1/4] Reindex fileset after lazy migrating files --- app/jobs/migrate_files_to_valkyrie_job.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/jobs/migrate_files_to_valkyrie_job.rb b/app/jobs/migrate_files_to_valkyrie_job.rb index 9facf0b9de..5da011c6e1 100644 --- a/app/jobs/migrate_files_to_valkyrie_job.rb +++ b/app/jobs/migrate_files_to_valkyrie_job.rb @@ -73,6 +73,8 @@ def migrate_files!(resource:) Hyrax.persister.save(resource: valkyrie_file) end end + # reindex the file set after migrating files to include characterization info + Hyrax.index_adapter.save(resource: resource) end def copy_attributes(valkyrie_file:, original_file:) From 3531de65af1799ca6d92b7793b77c9e3f1de2ad3 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 1 Nov 2024 11:48:28 -0400 Subject: [PATCH 2/4] Spec to verify indexing --- spec/jobs/migrate_files_to_valkyrie_job_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/jobs/migrate_files_to_valkyrie_job_spec.rb b/spec/jobs/migrate_files_to_valkyrie_job_spec.rb index a8d365ff55..c5138d63e6 100644 --- a/spec/jobs/migrate_files_to_valkyrie_job_spec.rb +++ b/spec/jobs/migrate_files_to_valkyrie_job_spec.rb @@ -35,5 +35,6 @@ described_class.new.attribute_mapping.each do |k, v| expect(valkyrized_file_set.original_file.send(k)).to match_array(pcdm_file.send(v)) end + expect(SolrDocument.find(valkyrized_file_set.id.to_s).width).to eq(222) end end From 004c9bc02d75f2c4dcb304197efed790a0f847d6 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 1 Nov 2024 15:20:10 -0400 Subject: [PATCH 3/4] Revise spec Passed locally but not on github... trying again --- spec/jobs/migrate_files_to_valkyrie_job_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/jobs/migrate_files_to_valkyrie_job_spec.rb b/spec/jobs/migrate_files_to_valkyrie_job_spec.rb index c5138d63e6..90f9be8ee4 100644 --- a/spec/jobs/migrate_files_to_valkyrie_job_spec.rb +++ b/spec/jobs/migrate_files_to_valkyrie_job_spec.rb @@ -35,6 +35,7 @@ described_class.new.attribute_mapping.each do |k, v| expect(valkyrized_file_set.original_file.send(k)).to match_array(pcdm_file.send(v)) end - expect(SolrDocument.find(valkyrized_file_set.id.to_s).width).to eq(222) + solr_doc = Hyrax.index_adapter.connection.get("select", params: { q: "id:#{valkyrized_file_set.id.to_s}" })["response"]["docs"].first + expect(solr_doc['width_is']).to eq(222) end end From 97d79ebee0fcaeb427302c08820fa6e9245bcc95 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 1 Nov 2024 17:03:30 -0400 Subject: [PATCH 4/4] Specify index adapter so spec doesn't use null --- spec/jobs/migrate_files_to_valkyrie_job_spec.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/jobs/migrate_files_to_valkyrie_job_spec.rb b/spec/jobs/migrate_files_to_valkyrie_job_spec.rb index 90f9be8ee4..fa9c775792 100644 --- a/spec/jobs/migrate_files_to_valkyrie_job_spec.rb +++ b/spec/jobs/migrate_files_to_valkyrie_job_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'wings' -RSpec.describe MigrateFilesToValkyrieJob, valkyrie_adapter: :freyja_adapter, perform_enqueued: [MigrateFilesToValkyrieJob] do +RSpec.describe MigrateFilesToValkyrieJob, index_adapter: :solr_index, valkyrie_adapter: :freyja_adapter, perform_enqueued: [MigrateFilesToValkyrieJob] do let(:user) { create(:user) } let(:content) { File.open(fixture_path + '/' + label) } let(:uploaded_file1) { build(:uploaded_file, file:) } @@ -23,9 +23,6 @@ before do allow(Hyrax.config).to receive(:valkyrie_transition?).and_return(true) - # allow(ActiveFedora::Base).to receive(:find).and_call_original - # allow(ActiveFedora::Base).to receive(:find).with(migrated_file_set.original_file.file_identifier.to_s).and_return(file_with_characterization) - # allow(File_Set).to receive(:find).with(fedora_file_set.id).and_return(fedora_file_set) end it "it migrates all derivatives along with a file" do