Skip to content

Commit

Permalink
make sure creators are a hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 3, 2019
1 parent b5bded4 commit a8399fa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@ def self.convert_affiliation_by_id(options={})
Doi.where(id: id..(id + 499)).find_each do |doi|
should_update = false
creators = Array.wrap(doi.creators).map do |c|
if c["affiliation"].nil?
if !c.is_a?(Hash)
logger.error "[MySQL] creators for DOI #{doi.doi} should be a hash."
elsif c["affiliation"].nil?
c["affiliation"] = []
should_update = true
elsif c["affiliation"].is_a?(String)
Expand Down Expand Up @@ -613,7 +615,9 @@ def self.convert_affiliation_by_id(options={})
c
end
contributors = Array.wrap(doi.contributors).map do |c|
if c["affiliation"].nil?
if !c.is_a?(Hash)
logger.error "[MySQL] creators for DOI #{doi.doi} should be a hash."
elsif c["affiliation"].nil?
c["affiliation"] = []
should_update = true
elsif c["affiliation"].is_a?(String)
Expand Down

0 comments on commit a8399fa

Please sign in to comment.