From 56a44381ad0c48227952b50ee76b245a9482a899 Mon Sep 17 00:00:00 2001 From: Eric O Date: Sat, 28 Oct 2023 14:45:32 -0400 Subject: [PATCH] Update sync_record rake task to sync_records (and allow caller to supply multiple bib ids) --- lib/tasks/hysync.rake | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/tasks/hysync.rake b/lib/tasks/hysync.rake index e166200..66ac699 100644 --- a/lib/tasks/hysync.rake +++ b/lib/tasks/hysync.rake @@ -29,19 +29,22 @@ namespace :hysync do ).marc_sync_error_email.deliver end - task :sync_record => :environment do + task :sync_records => :environment do runner = Hysync::MarcSynchronizer::Runner.new(HYACINTH_CONFIG, VOYAGER_CONFIG) force_update = (ENV['force_update'] == 'true') dry_run = (ENV['dry_run'] == 'true') voyager = runner.instance_variable_get(:@voyager_client) voyager.instance_variable_get(:@z3950_config)[:use_cached_results] = false - marc_record = voyager.find_by_bib_id(ENV['bib_id']) - base_digital_object_data = Hysync::MarcSynchronizer::Runner.default_digital_object_data - success, errors = runner.create_or_update_hyacinth_record(marc_record, base_digital_object_data, force_update, dry_run) - if success - puts 'Success!' - else - puts 'Errors: ' + errors.inspect + + (ENV['bib_ids'] || '').split(',').each do |bib_id| + marc_record = voyager.find_by_bib_id(bib_id) + base_digital_object_data = Hysync::MarcSynchronizer::Runner.default_digital_object_data + success, errors = runner.create_or_update_hyacinth_record(marc_record, base_digital_object_data, force_update, dry_run) + if success + puts "(#{bib_id}) Success!" + else + raise "Error for record #{bib_id}: " + errors.inspect + end end end