diff --git a/lib/tasks/client.rake b/lib/tasks/client.rake index fc384c649..7e9c294f9 100644 --- a/lib/tasks/client.rake +++ b/lib/tasks/client.rake @@ -108,6 +108,27 @@ namespace :client do end end + desc 'Import DOIs by client' + task :import_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 + + # import DOIs for client + puts "#{client.dois.length} DOIs will be imported." + client.dois.find_each do |doi| + Doi.import_one(doi: doi.doi) + puts "DOI #{doi.doi} imported." + end + end + desc 'Index DOIs by client' task :index_all_dois => :environment do if ENV['CLIENT_ID'].nil?