Skip to content

Commit

Permalink
use update_columns to update affiliations. #324
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 3, 2019
1 parent 2e964a1 commit b5bded4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,16 @@ def self.convert_affiliation_by_id(options={})
end

if should_update
Doi.non_audited_columns = [:creators, :contributors]
doi.update_attributes(creators: creators, contributors: contributors)
doi.update_columns(creators: creators, contributors: contributors)
count += 1
end
end

logger.info "[Elasticsearch] Converted affiliations for #{count} DOIs with IDs #{id} - #{(id + 499)}." if count > 0
logger.info "[MySQL] Converted affiliations for #{count} DOIs with IDs #{id} - #{(id + 499)}." if count > 0

count
rescue Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge, Faraday::ConnectionFailed, ActiveRecord::LockWaitTimeout => error
logger.info "[Elasticsearch] Error #{error.message} converting affiliations for DOIs with IDs #{id} - #{(id + 499)}."
rescue Faraday::ConnectionFailed, ActiveRecord::LockWaitTimeout => error
logger.info "[MySQL] Error #{error.message} converting affiliations for DOIs with IDs #{id} - #{(id + 499)}."
end

def doi=(value)
Expand Down

0 comments on commit b5bded4

Please sign in to comment.