Skip to content

Commit

Permalink
Merge pull request #568 from datacite/set-registration-agency
Browse files Browse the repository at this point in the history
Set registration-agency
  • Loading branch information
Martin Fenner authored Jun 16, 2020
2 parents 7dc7827 + 2e85626 commit aa9b3fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/jobs/update_doi_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class UpdateDoiJob < ActiveJob::Base
queue_as :lupo_background

def perform(doi_id, options={})
doi = Doi.where(doi: doi_id).first

if doi.blank?
Rails.logger.error "[UpdateDoi] Error updating DOI " + doi_id + ": not found"
elsif doi.update_attributes(version: doi.version.to_i + 1)
Rails.logger.debug "[UpdateDoi] Successfully updated DOI " + doi_id
else
Rails.logger.error "[UpdateDoi] Error updating DOI " + doi_id + ": " + doi.errors.messages.inspect
end
end
end
12 changes: 12 additions & 0 deletions lib/tasks/doi.rake
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ namespace :doi do
Doi.loop_through_dois(options)
end

desc "Set registration agency"
task set_registration_agency: :environment do
options = {
from_id: (ENV["FROM_ID"] || Doi.minimum(:id)).to_i,
until_id: (ENV["UNTIL_ID"] || Doi.maximum(:id)).to_i,
query: "agency:DataCite OR agency:Crossref OR -agency:*",
label: "[SetRegistrationAgency]",
job_name: "UpdateDoiJob",
}
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 aa9b3fd

Please sign in to comment.