Skip to content

Commit

Permalink
reimport metadata when there are problems with doi indexing. datacite…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 23, 2020
1 parent f00f1c4 commit 7ff3af4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ GEM
latex-decode (~> 0.0)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bolognese (1.5)
bolognese (1.5.1)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
Expand Down
13 changes: 9 additions & 4 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,17 @@ def self.import_by_id(options={})
type: Doi.document_type,
body: dois.map { |doi| { index: { _id: doi.id, data: doi.as_indexed_json } } }

# log errors
errors += response['items'].map { |k, v| k.values.first['error'] }.compact.length
response['items'].select { |k, v| k.values.first['error'].present? }.each do |err|
Rails.logger.error "[Elasticsearch] " + err.inspect
# try to handle errors
response['items'].select { |k, v| k.values.first['error'].present? }.each do |item|
import_one(doi_id: item.dig("index", "_id").to_i)
end

# log errors
# errors += response['items'].map { |k, v| k.values.first['error'] }.compact.length
# response['items'].select { |k, v| k.values.first['error'].present? }.each do |err|
# Rails.logger.error "[Elasticsearch] " + err.inspect
# end

count += dois.length
end

Expand Down

0 comments on commit 7ff3af4

Please sign in to comment.