Skip to content

Commit

Permalink
backfill index by date created
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 14, 2018
1 parent 42b1ede commit c27acf5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand All @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/shoryuken.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
concurrency: 15
concurrency: 10
delay: 0
pidfile: tmp/pids/shoryuken.pid
queues:
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/doi.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/tasks/doi_rake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit c27acf5

Please sign in to comment.