Skip to content

Commit

Permalink
better messaging during import. datacite/datacite#965
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 19, 2020
1 parent d6f2e4a commit 3cd5d53
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/jobs/doi_not_indexed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class DoiNotIndexedJob < ApplicationJob
queue_as :lupo_background

def perform(client_id, _options = {})
Doi.import_by_client(client_id: client_id)
def perform(client_id, options = {})
Doi.import_by_client(client_id, options)
end
end
4 changes: 2 additions & 2 deletions app/models/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@ def self.import_dois_not_indexed(query: nil)

# loop through repositories that have DOIs not indexed in Elasticsearch
table.each do |row|
Rails.logger.info "Indexing #{row["DOIs in Database"]} DOIs (#{row["DOIs missing"]} missing) for repository #{row["Repository ID"]}."
DoiNotIndexedJob.perform_later(row["Repository ID"])
Rails.logger.info "Started to import #{row["DOIs in Database"]} DOIs (#{row["DOIs missing"]} missing) for repository #{row["Repository ID"]}."
DoiNotIndexedJob.perform_later(row["Repository ID"], doi_count: row["DOIs in Database"], missing_count: row["DOIs missing"])
end
end

Expand Down
10 changes: 3 additions & 7 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ def self.import_one(doi_id: nil)
message
end

def self.import_by_client(client_id: nil)
def self.import_by_client(client_id, options={})
client = ::Client.where(symbol: client_id).first
return nil if client.blank?

Expand Down Expand Up @@ -1271,14 +1271,10 @@ def self.import_by_client(client_id: nil)
end

count += dois.length
Rails.logger.info "[Elasticsearch] Imported #{count} DOIs for repository #{client_id}."
Rails.logger.info "[Elasticsearch] So far imported #{count} DOIs for repository #{client_id}."
end

if errors > 1
Rails.logger.error "[Elasticsearch] #{errors} errors importing #{count} DOIs for repository #{client_id}."
elsif count > 0
Rails.logger.info "[Elasticsearch] Imported a total of #{count} DOIs for repository #{client_id}."
end
Rails.logger.info "[Elasticsearch] Imported a total of #{count} DOIs (#{options[:missing_count].to_i - errors} out of #{options[:missing_count].to_i} errors resolved) for repository #{client_id}."

count
rescue Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge, Faraday::ConnectionFailed, ActiveRecord::LockWaitTimeout => e
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/client.rake
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace :client do

# import DOIs for client
puts "#{client.dois.length} DOIs will be imported."
Doi.import_by_client(client_id: ENV["CLIENT_ID"])
Doi.import_by_client(ENV["CLIENT_ID"])
end

desc "Import dois not indexed"
Expand Down

0 comments on commit 3cd5d53

Please sign in to comment.