From 6e35753ee2c2cfde8754c6bdfd290bca2a253036 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 30 Jul 2019 14:31:15 +0200 Subject: [PATCH] uodate state for ethz dois. datacite/datacite#793 --- app/jobs/url_job.rb | 4 ++-- app/models/doi.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/jobs/url_job.rb b/app/jobs/url_job.rb index 841199650..b7ba4163d 100644 --- a/app/jobs/url_job.rb +++ b/app/jobs/url_job.rb @@ -14,13 +14,13 @@ def perform(doi_id) response = Doi.get_doi(doi: doi.doi, agency: doi.agency) url = response.body.dig('data', 'values', 0, 'data', 'value') if url.present? - if (doi.is_registered_or_findable? || %w(europ crossref medra kisti jalc op).include?(doi.provider_id)) && doi.minted.blank? + if (doi.is_registered_or_findable? || %w(ethz europ crossref medra kisti jalc op).include?(doi.provider_id)) && doi.minted.blank? doi.update_attributes(url: url, minted: Time.zone.now) else doi.update_attributes(url: url) end - doi.update_attributes(aasm_state: "findable") if %w(europ crossref medra kisti jalc op).include?(doi.provider_id) + doi.update_attributes(aasm_state: "findable") if %w(ethz europ crossref medra kisti jalc op).include?(doi.provider_id) doi.__elasticsearch__.index_document diff --git a/app/models/doi.rb b/app/models/doi.rb index 42b68eab9..43c3bb1f3 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -727,11 +727,11 @@ def self.delete_dois_by_prefix(prefix, options={}) end # register DOIs in the handle system that have not been registered yet - # providers ethz and europ register their DOIs in the handle system themselves and are ignored + # provider europ registers their DOIs in the handle system themselves and are ignored def self.set_handle logger = Logger.new(STDOUT) - response = Doi.query("-registered:* +url:* -aasm_state:draft -provider_id:ethz -provider_id:europ", page: { size: 1, cursor: [] }) + response = Doi.query("-registered:* +url:* -aasm_state:draft -provider_id:europ -agency:Crossref", page: { size: 1, cursor: [] }) logger.info "#{response.results.total} DOIs found that are not registered in the Handle system." if response.results.total > 0 @@ -739,7 +739,7 @@ def self.set_handle cursor = [] while response.results.results.length > 0 do - response = Doi.query("-registered:* +url:* -aasm_state:draft -provider_id:ethz -provider_id:europ", page: { size: 1000, cursor: cursor }) + response = Doi.query("-registered:* +url:* -aasm_state:draft -provider_id:europ -agency:Crossref", page: { size: 1000, cursor: cursor }) break unless response.results.results.length > 0 logger.info "[Handle] Register #{response.results.results.length} DOIs in the handle system starting with _id #{response.results.to_a.first[:_id]}." @@ -779,7 +779,7 @@ def self.set_url def self.set_minted logger = Logger.new(STDOUT) - response = Doi.query("url:* +provider_id:ethz +aasm_state:draft", page: { size: 1, cursor: [] }) + response = Doi.query("provider_id:ethz AND +aasm_state:draft +url:*", page: { size: 1, cursor: [] }) logger.info "#{response.results.total} draft DOIs from provider ETHZ found in the database." if response.results.total > 0 @@ -787,7 +787,7 @@ def self.set_minted cursor = [] while response.results.results.length > 0 do - response = Doi.query("url:* +provider_id:ethz +aasm_state:draft", page: { size: 1000, cursor: cursor }) + response = Doi.query("provider_id:ethz AND +aasm_state:draft +url:*", page: { size: 1000, cursor: cursor }) break unless response.results.results.length > 0 logger.info "[MySQL] Set minted for #{response.results.results.length} DOIs starting with _id #{response.results.to_a.first[:_id]}."