Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed May 27, 2020
1 parent 86a68d2 commit 0bf8e2a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,9 @@ def self.import_by_client(client_id: nil)
body: dois.map { |doi| { index: { _id: doi.id, data: doi.as_indexed_json } } }

# try to handle errors
response['items'].select { |k, v| k.values.first['error'].present? }.each do |item|
errors += 1
errors_in_response = response['items'].select { |k, v| k.values.first['error'].present? }
errors += errors_in_response.length
errors_in_response.each do |item|
Rails.logger.error "[Elasticsearch] " + item.inspect
doi_id = item.dig("index", "_id").to_i
import_one(doi_id: doi_id) if doi_id > 0
Expand Down Expand Up @@ -1039,7 +1040,9 @@ def self.import_by_id(options={})
body: dois.map { |doi| { index: { _id: doi.id, data: doi.as_indexed_json } } }

# try to handle errors
errors += response['items'].select { |k, v| k.values.first['error'].present? }.each do |item|
errors_in_response = response['items'].select { |k, v| k.values.first['error'].present? }
errors += errors_in_response.length
errors_in_response.each do |item|
Rails.logger.error "[Elasticsearch] " + item.inspect
doi_id = item.dig("index", "_id").to_i
import_one(doi_id: doi_id) if doi_id > 0
Expand Down

0 comments on commit 0bf8e2a

Please sign in to comment.