Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reindex fileset after file lazy migration #6954

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/jobs/migrate_files_to_valkyrie_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:)
Expand Down
7 changes: 3 additions & 4 deletions spec/jobs/migrate_files_to_valkyrie_job_spec.rb
Original file line number Diff line number Diff line change
@@ -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:) }
Expand All @@ -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
Expand All @@ -35,5 +32,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
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
Loading