From fa38299c83f717dc48ef06fb4b5491cb23cb25b4 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Mon, 15 Oct 2018 21:23:02 +0200 Subject: [PATCH] index dois by year --- lib/tasks/doi.rake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tasks/doi.rake b/lib/tasks/doi.rake index 48a8531ae..89ada32c6 100644 --- a/lib/tasks/doi.rake +++ b/lib/tasks/doi.rake @@ -8,8 +8,13 @@ namespace :doi do desc 'Index all DOIs' task :index => :environment do - from_date = ENV['FROM_DATE'] || Date.current.beginning_of_month.strftime("%F") - until_date = ENV['UNTIL_DATE'] || Date.current.end_of_month.strftime("%F") + if ENV['YEAR'].present? + from_date = "#{ENV['YEAR']}-01-01" + until_date = "#{ENV['YEAR']}-12-31" + else + from_date = ENV['FROM_DATE'] || Date.current.beginning_of_month.strftime("%F") + until_date = ENV['UNTIL_DATE'] || Date.current.end_of_month.strftime("%F") + end response = Doi.index(from_date: from_date, until_date: until_date) puts response