Skip to content

Commit

Permalink
refresh crossref metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 23, 2020
1 parent 434c19d commit 879fddf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/jobs/doi_refresh_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class DoiRefreshJob < ActiveJob::Base
queue_as :lupo_background

# retry_on ActiveRecord::Deadlocked, wait: 10.seconds, attempts: 3
# retry_on Faraday::TimeoutError, wait: 10.minutes, attempts: 3

# discard_on ActiveJob::DeserializationError

rescue_from ActiveJob::DeserializationError, Elasticsearch::Transport::Transport::Errors::BadRequest do |error|
Rails.logger.error error.message
end

def perform(id, options={})
Event.import_doi(id, options.merge(refresh: true))
end
end
12 changes: 12 additions & 0 deletions lib/tasks/doi.rake
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ namespace :doi do
Doi.loop_through_dois(options)
end

# until all Crossref DOIs are indexed as otherDoi
desc "Refresh metadata"
task refresh: :environment do
options = {
query: ENV["QUERY"],
label: "[RefreshMetadata]",
job_name: "DoiRefreshJob",
cursor: ENV["CURSOR"],
}
puts Doi.loop_through_dois(options)
end

desc 'Convert affiliations to new format'
task :convert_affiliations => :environment do
from_id = (ENV['FROM_ID'] || Doi.minimum(:id)).to_i
Expand Down

0 comments on commit 879fddf

Please sign in to comment.