From c27acf54ac86dd5a6092576e273817a0f70b0c02 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sun, 14 Oct 2018 19:01:15 -0400 Subject: [PATCH] backfill index by date created --- app/models/doi.rb | 6 +++--- config/shoryuken.yml | 2 +- lib/tasks/doi.rake | 2 +- spec/lib/tasks/doi_rake_spec.rb | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 419f48bec..b7bf88ee3 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -239,7 +239,7 @@ def self.index(options={}) DoiIndexByDayJob.perform_later(from_date: d.strftime("%F")) end - "Queued indexing for DOIs updated from #{from_date.strftime("%F")} until #{until_date.strftime("%F")}." + "Queued indexing for DOIs created from #{from_date.strftime("%F")} until #{until_date.strftime("%F")}." end def self.index_by_day(options={}) @@ -250,7 +250,7 @@ def self.index_by_day(options={}) logger = Logger.new(STDOUT) - Doi.where("updated >= ?", from_date.strftime("%F") + " 00:00:00").where("updated <= ?", until_date.strftime("%F") + " 00:00:00").find_in_batches(batch_size: 100) do |dois| + Doi.where("created >= ?", from_date.strftime("%F") + " 00:00:00").where("created < ?", until_date.strftime("%F") + " 00:00:00").find_in_batches(batch_size: 100) do |dois| response = Doi.__elasticsearch__.client.bulk \ index: Doi.index_name, type: Doi.document_type, @@ -260,7 +260,7 @@ def self.index_by_day(options={}) count += dois.length end - logger.info "[Elasticsearch] #{errors} errors indexing #{count} DOIs updated on #{from_date.strftime("%F")}." + logger.info "[Elasticsearch] #{errors} errors indexing #{count} DOIs created on #{from_date.strftime("%F")}." end def uid diff --git a/config/shoryuken.yml b/config/shoryuken.yml index f1568e885..11b7d2b23 100644 --- a/config/shoryuken.yml +++ b/config/shoryuken.yml @@ -1,4 +1,4 @@ -concurrency: 15 +concurrency: 10 delay: 0 pidfile: tmp/pids/shoryuken.pid queues: diff --git a/lib/tasks/doi.rake b/lib/tasks/doi.rake index d4a5c273d..48a8531ae 100644 --- a/lib/tasks/doi.rake +++ b/lib/tasks/doi.rake @@ -20,7 +20,7 @@ namespace :doi do from_date = ENV['FROM_DATE'] || Date.current.strftime("%F") Doi.index_by_day(from_date: from_date) - puts "DOIs updated on #{from_date} indexed." + puts "DOIs created on #{from_date} indexed." end desc 'Set state' diff --git a/spec/lib/tasks/doi_rake_spec.rb b/spec/lib/tasks/doi_rake_spec.rb index 92415e8f6..137ef8c8c 100644 --- a/spec/lib/tasks/doi_rake_spec.rb +++ b/spec/lib/tasks/doi_rake_spec.rb @@ -8,7 +8,7 @@ ENV['UNTIL_DATE'] = "2018-08-05" let!(:doi) { create_list(:doi, 10) } - let(:output) { "Queued indexing for DOIs updated from 2018-01-04 until 2018-08-05.\n" } + let(:output) { "Queued indexing for DOIs created from 2018-01-04 until 2018-08-05.\n" } it "prerequisites should include environment" do expect(subject.prerequisites).to include("environment") @@ -31,7 +31,7 @@ include_context "rake" let!(:doi) { create_list(:doi, 10) } - let(:output) { "DOIs updated on 2018-01-04 indexed.\n" } + let(:output) { "DOIs created on 2018-01-04 indexed.\n" } it "prerequisites should include environment" do expect(subject.prerequisites).to include("environment")