lib/searchkick/bulk_indexer.rb in searchkick-3.0.2 vs lib/searchkick/bulk_indexer.rb in searchkick-3.0.3

- old
+ new

@@ -49,10 +49,14 @@ def bulk_update(records, method_name) Searchkick.indexer.queue(records.map { |r| RecordData.new(index, r).update_data(method_name) }) end + def batches_left + Searchkick.with_redis { |r| r.scard(batches_key) } + end + private def import_or_update(records, method_name, async) if records.any? if async @@ -132,16 +136,16 @@ end yield items if items.any? end def bulk_reindex_job(scope, batch_id, options) + Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) } Searchkick::BulkReindexJob.perform_later({ class_name: scope.model_name.name, index_name: index.name, batch_id: batch_id }.merge(options)) - Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) } end def with_retries retries = 0 @@ -152,13 +156,9 @@ retries += 1 retry end raise e end - end - - def batches_left - Searchkick.with_redis { |r| r.scard(batches_key) } end def batches_key "searchkick:reindex:#{index.name}:batches" end