From 562fc8628df7cd2d63faf3a221660c2ecc642d2c Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Tue, 15 Sep 2020 13:37:51 +0200 Subject: [PATCH] Add rake task to trigger updatedois based on query --- lib/tasks/doi.rake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/tasks/doi.rake b/lib/tasks/doi.rake index f79cefc34..cb7122359 100644 --- a/lib/tasks/doi.rake +++ b/lib/tasks/doi.rake @@ -154,6 +154,24 @@ namespace :doi do Doi.loop_through_dois(options) end + desc "Trigger DOI Update based on query" + task update_dois_by_query: :environment do + # Ensure we have to specify a query of some kind. + if ENV['QUERY'].nil? + puts "ENV['QUERY'] is required" + exit + end + + options = { + query: ENV["QUERY"], + label: "[UpdateDoiByQuery]", + job_name: "UpdateDoiJob", + cursor: ENV["CURSOR"].present? ? Base64.urlsafe_decode64(ENV["CURSOR"]).split(",", 2) : [], + } + puts Doi.loop_through_dois(options) + end + + # until all Crossref DOIs are indexed as otherDoi desc "Refresh metadata" task refresh: :environment do