Skip to content

Commit

Permalink
Merge pull request #5953 from avalonmediasystem/cjcolvar-patch-3
Browse files Browse the repository at this point in the history
Speed up section list migration by optimizing solr queries
  • Loading branch information
cjcolvar authored Jul 24, 2024
2 parents f54037c + 76f63de commit c65d675
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tasks/avalon_migrations.rake
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ namespace :avalon do
task media_object_section_list: :environment do
error_ids = []
mo_count = MediaObject.count
ids_to_migrate = ActiveFedora::SolrService.query("has_model_ssim:MediaObject AND NOT section_list_ssim:[* TO *]", rows: mo_count).pluck("id")
ids_to_migrate = ActiveFedora::SolrService.query("has_model_ssim:MediaObject AND NOT section_list_ssim:[* TO *]", fl: [:id], rows: mo_count).pluck("id")
puts "Migrating #{ids_to_migrate.size} out of #{mo_count} Media Objects."
ids_to_migrate.each do |id|
MediaObject.find(id).save!(validate: false)
rescue StandardError => error
error_ids += [id]
puts "Error migrating #{id}: #{error.message}"
end
remaining_ids_count = ActiveFedora::SolrService.query("has_model_ssim:MediaObject AND NOT section_list_ssim:[* TO *]", rows: mo_count).size
remaining_ids_count = ActiveFedora::SolrService.query("has_model_ssim:MediaObject AND NOT section_list_ssim:[* TO *]", fl: [:id], rows: mo_count).size
if error_ids.size > 0
puts "Migration finished running but #{error_ids.size} Media Objects failed to migrate. Try running the migration again."
elsif remaining_ids_count > 0
Expand Down

0 comments on commit c65d675

Please sign in to comment.