diff --git a/app/models/doi.rb b/app/models/doi.rb index 258433c91..b802b49bf 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -800,6 +800,29 @@ def self.set_url end end + def self.set_minted + logger = Logger.new(STDOUT) + + response = Doi.query("url:* +provider_id:ethz +aasm_state:draft", page: { size: 0, cursor: 1 }) + logger.info "#{response.results.total} draft DOIs from provider ETHZ found in the database." + + if response.results.total > 0 + # walk through results using cursor + prev_cursor = 0 + cursor = 1 + + while cursor > prev_cursor do + response = Doi.query("url:* +provider_id:ethz +aasm_state:draft", page: { size: 1000, cursor: cursor }) + prev_cursor = cursor + cursor = Array.wrap(response.results.results.last[:sort]).first + + response.results.results.each do |d| + UrlJob.perform_later(d.doi) + end + end + end + end + # save to metadata table when xml has changed def save_metadata metadata.build(doi: self, xml: xml, namespace: schema_version) if xml.present? && xml_changed? diff --git a/config/initializers/_version.rb b/config/initializers/_version.rb index 0b69e9a50..e444e60ea 100644 --- a/config/initializers/_version.rb +++ b/config/initializers/_version.rb @@ -1,5 +1,5 @@ module Lupo class Application - VERSION = "2.3.27" + VERSION = "2.3.28" end end \ No newline at end of file diff --git a/lib/tasks/doi.rake b/lib/tasks/doi.rake index 56c7de794..0502c72bc 100644 --- a/lib/tasks/doi.rake +++ b/lib/tasks/doi.rake @@ -106,6 +106,11 @@ namespace :doi do Doi.set_handle end + desc 'Set minted' + task :set_minted => :environment do + Doi.set_minted + end + desc 'Delete DOIs with test prefix older than one month' task :delete_test_dois => :environment do from_date = ENV['FROM_DATE'] || Time.zone.now - 1.month