Skip to content

Commit

Permalink
polish xml import from metadata table
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 27, 2018
1 parent 7e7fe5b commit 86ef13e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?('<?xml version=') ? doi.current_metadata.xml.force_encoding("UTF-8") : 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
Expand Down

0 comments on commit 86ef13e

Please sign in to comment.