From 47c8fc67da0eca568f1fe59d2d114255a039948c Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 20 Feb 2022 17:22:06 -0800 Subject: [PATCH] Reordered methods [skip ci] --- lib/searchkick/relation_indexer.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/searchkick/relation_indexer.rb b/lib/searchkick/relation_indexer.rb index 783750b..9e9674b 100644 --- a/lib/searchkick/relation_indexer.rb +++ b/lib/searchkick/relation_indexer.rb @@ -62,16 +62,6 @@ module Searchkick end end - def full_reindex_async(relation) - batch_id = 1 - class_name = relation.searchkick_options[:class_name] - - in_batches(relation) do |items| - batch_job(class_name, batch_id, items.map(&:id)) - batch_id += 1 - end - end - def in_batches(relation, &block) if relation.respond_to?(:find_in_batches) # remove order to prevent possible warnings @@ -95,6 +85,20 @@ module Searchkick yield items if items.any? end + def batch_size + @batch_size ||= index.options[:batch_size] || 1000 + end + + def full_reindex_async(relation) + batch_id = 1 + class_name = relation.searchkick_options[:class_name] + + in_batches(relation) do |items| + batch_job(class_name, batch_id, items.map(&:id)) + batch_id += 1 + end + end + def batch_job(class_name, batch_id, record_ids) Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) } Searchkick::BulkReindexJob.perform_later( @@ -108,9 +112,5 @@ module Searchkick def batches_key "searchkick:reindex:#{index.name}:batches" end - - def batch_size - @batch_size ||= index.options[:batch_size] || 1000 - end end end -- libgit2 0.21.0