From c9a2640b0fd763a6a005a3d9dfbb8a9c0d56d244 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 26 Dec 2018 22:46:08 +0100 Subject: [PATCH] more error reporting for doi import --- app/models/doi.rb | 30 +++++++++++++++++++++++++----- lib/tasks/client.rake | 2 +- lib/tasks/doi.rake | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 6ec3b0b20..001c1fca3 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -336,11 +336,21 @@ def self.find_by_id(id, options={}) }) end - def self.import_one(doi: nil) - doi = Doi.where(doi: doi).first - return nil unless doi.present? + def self.import_one(doi_id: nil) + logger = Logger.new(STDOUT) + + doi = Doi.where(doi: doi_id).first + unless doi.present? + logger.error "[MySQL] DOI " + doi_id + " not found." + return nil + end string = doi.current_metadata.present? && doi.current_metadata.xml.to_s.start_with?(' error logger.error "[MySQL] Error importing metadata for " + doi.doi + ": " + error.message Bugsnag.notify(error) @@ -388,6 +398,11 @@ def self.import_by_day(options={}) begin # ignore broken xml string = doi.current_metadata.present? && doi.current_metadata.xml.to_s.start_with?(' error puts "[MySQL] Error importing metadata for " + doi.doi + ": " + error.message diff --git a/lib/tasks/doi.rake b/lib/tasks/doi.rake index fb8ee4ac0..0982b7525 100644 --- a/lib/tasks/doi.rake +++ b/lib/tasks/doi.rake @@ -47,7 +47,7 @@ namespace :doi do exit end - Doi.import_one(doi: ENV['DOI']) + Doi.import_one(doi_id: ENV['DOI']) end desc 'Index all DOIs'