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'