From 86ef13e359b3b869da3226fcb607cfa10500733f Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 27 Dec 2018 08:41:00 +0100 Subject: [PATCH] polish xml import from metadata table --- app/models/doi.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 142f3c898..bb2812a5a 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -345,7 +345,7 @@ def self.import_one(doi_id: nil) return nil end - string = doi.current_metadata.present? ? doi.from_xml(doi.current_metadata.xml).to_s.force_encoding("UTF-8").presence : nil + string = doi.current_metadata.present? ? doi.from_xml(doi.current_metadata.xml.to_s.force_encoding("UTF-8")) : nil unless string.present? logger.error "[MySQL] No metadata for DOI " + doi.doi + " found: " + doi.current_metadata.inspect return nil @@ -397,7 +397,7 @@ def self.import_by_day(options={}) Doi.where(created: from_date.midnight..from_date.end_of_day).find_each do |doi| begin # ignore broken xml - string = doi.current_metadata.present? ? doi.from_xml(doi.current_metadata.xml).to_s.force_encoding("UTF-8").presence : nil + string = doi.current_metadata.present? ? doi.from_xml(doi.current_metadata.xml.to_s.force_encoding("UTF-8")) : nil unless string.present? logger.error "[MySQL] No metadata for DOI " + doi.doi + " found." return nil @@ -433,7 +433,7 @@ def self.import_by_day_missing(options={}) Doi.where(schema_version: nil).where(created: from_date.midnight..from_date.end_of_day).find_each do |doi| begin - string = doi.current_metadata.to_s.start_with?('