Commit fc4a9dd7c235acf9bec6b8d9832df84ba48f487d

Authored by Andrew Kane
1 parent 50758c19

Made batch_size argument for more consistent code [skip ci]

Showing 1 changed file with 4 additions and 3 deletions   Show diff stats
lib/searchkick/relation_indexer.rb
... ... @@ -41,7 +41,8 @@ module Searchkick
41 41 record_indexer.reindex(items, **reindex_options)
42 42 end
43 43 else
44   - each_batch(relation) do |items|
  44 + # TODO handle resume option
  45 + each_batch(relation, batch_size: batch_size) do |items|
45 46 record_indexer.reindex(items, **reindex_options)
46 47 end
47 48 end
... ... @@ -93,14 +94,14 @@ module Searchkick
93 94 batch_id = 1
94 95 # TODO remove any eager loading
95 96 scope = scope.only(:_id) if scope.respond_to?(:only)
96   - each_batch(scope) do |items|
  97 + each_batch(scope, batch_size: batch_size) do |items|
97 98 bulk_reindex_job scope, batch_id, record_ids: items.map { |i| i.id.to_s }
98 99 batch_id += 1
99 100 end
100 101 end
101 102 end
102 103  
103   - def each_batch(scope)
  104 + def each_batch(scope, batch_size:)
104 105 # https://github.com/karmi/tire/blob/master/lib/tire/model/import.rb
105 106 # use cursor for Mongoid
106 107 items = []
... ...