From 6e993418f93f5edd71989119d1f4a15fc623edd3 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 26 Dec 2018 18:04:43 +0100 Subject: [PATCH] index all dois by client --- lib/tasks/client.rake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/tasks/client.rake b/lib/tasks/client.rake index 535516c25..fc384c649 100644 --- a/lib/tasks/client.rake +++ b/lib/tasks/client.rake @@ -107,4 +107,25 @@ namespace :client do puts "Client prefix for client #{target.symbol} and prefix #{prefix} created." end end + + desc 'Index DOIs by client' + task :index_all_dois => :environment do + if ENV['CLIENT_ID'].nil? + puts "ENV['CLIENT_ID'] is required." + exit + end + + client = Client.where(deleted_at: nil).where(symbol: ENV['CLIENT_ID']).first + if client.nil? + puts "Client not found for client ID #{ENV['CLIENT_ID']}." + exit + end + + # index DOIs for client + puts "#{client.dois.length} DOIs will be indexed." + client.dois.find_each do |doi| + doi.__elasticsearch__.index_document + puts "DOI #{doi.doi} indexed." + end + end end \ No newline at end of file