Skip to content

Commit

Permalink
Give the batch size a name
Browse files Browse the repository at this point in the history
  • Loading branch information
elzj committed Sep 14, 2014
1 parent f5497ca commit ae0ea64
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models/search/indexer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class Indexer

BATCH_SIZE = 1000

##################
# CLASS METHODS
##################
Expand Down Expand Up @@ -52,9 +54,9 @@ def self.index_all(options={})
end

def self.index_from_db
total = (indexables.count / 1000) + 1
total = (indexables.count / BATCH_SIZE) + 1
i = 1
indexables.find_in_batches do |group|
indexables.find_in_batches(batch_size: BATCH_SIZE) do |group|
puts "Reindexing #{klass} batch #{i} of #{total}"
self.new(group.map(&:id)).index_documents
i += 1
Expand Down

0 comments on commit ae0ea64

Please sign in to comment.