From 3813b36416f87907d9da0e1cf7d86b69ffc1fc94 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 18 Sep 2018 09:13:47 +0200 Subject: [PATCH] better logging of bulk doi transfer --- app/jobs/transfer_job.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/jobs/transfer_job.rb b/app/jobs/transfer_job.rb index ee323cd45..36d3a2873 100644 --- a/app/jobs/transfer_job.rb +++ b/app/jobs/transfer_job.rb @@ -2,13 +2,15 @@ class TransferJob < ActiveJob::Base queue_as :lupo_background def perform(doi_id, options={}) + logger = Logger.new(STDOUT) doi = Doi.where(doi: doi_id).first - if doi.present? - doi.update_attributes(datacentre: options[:target_id]) - else - logger = Logger.new(STDOUT) + if doi.blank? logger.info "[Transfer] Error transferring DOI " + doi_id + ": not found" + elsif doi.update_attributes(datacentre: options[:target_id]) + logger.info "[Transfer] Successfully transferred DOI " + doi_id + else + logger.info "[Transfer] Error transferring DOI " + doi_id + ": " + errors.inspect end end end \ No newline at end of file