Skip to content

Commit bd6a122

Browse files
Brian Kellythatbudakguy
authored andcommitted
Refactor solution
1 parent 4f7133b commit bd6a122

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

lib/geo_combine/indexer.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,10 @@ def index(docs)
3535
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
3636

3737
# Index in batches; set batch size via BATCH_SIZE
38-
batch = []
39-
docs.each do |doc, path|
40-
if batch.size < @batch_size
41-
batch << [doc, path]
42-
else
43-
total_indexed += index_batch(batch)
44-
batch = [[doc, path]]
45-
end
38+
docs.each_slice(@batch_size) do |slice|
39+
batch = slice.map { |doc, path| [doc, path] }
40+
total_indexed += index_batch(batch)
4641
end
47-
total_indexed += index_batch(batch) unless batch.empty?
4842

4943
# Issue a commit to make sure all documents are indexed
5044
@solr.commit

0 commit comments

Comments
 (0)