Commit 47c8fc67da0eca568f1fe59d2d114255a039948c
1 parent
18770f8b
Exists in
master
and in
2 other branches
Reordered methods [skip ci]
Showing
1 changed file
with
14 additions
and
14 deletions
Show diff stats
lib/searchkick/relation_indexer.rb
@@ -62,16 +62,6 @@ module Searchkick | @@ -62,16 +62,6 @@ module Searchkick | ||
62 | end | 62 | end |
63 | end | 63 | end |
64 | 64 | ||
65 | - def full_reindex_async(relation) | ||
66 | - batch_id = 1 | ||
67 | - class_name = relation.searchkick_options[:class_name] | ||
68 | - | ||
69 | - in_batches(relation) do |items| | ||
70 | - batch_job(class_name, batch_id, items.map(&:id)) | ||
71 | - batch_id += 1 | ||
72 | - end | ||
73 | - end | ||
74 | - | ||
75 | def in_batches(relation, &block) | 65 | def in_batches(relation, &block) |
76 | if relation.respond_to?(:find_in_batches) | 66 | if relation.respond_to?(:find_in_batches) |
77 | # remove order to prevent possible warnings | 67 | # remove order to prevent possible warnings |
@@ -95,6 +85,20 @@ module Searchkick | @@ -95,6 +85,20 @@ module Searchkick | ||
95 | yield items if items.any? | 85 | yield items if items.any? |
96 | end | 86 | end |
97 | 87 | ||
88 | + def batch_size | ||
89 | + @batch_size ||= index.options[:batch_size] || 1000 | ||
90 | + end | ||
91 | + | ||
92 | + def full_reindex_async(relation) | ||
93 | + batch_id = 1 | ||
94 | + class_name = relation.searchkick_options[:class_name] | ||
95 | + | ||
96 | + in_batches(relation) do |items| | ||
97 | + batch_job(class_name, batch_id, items.map(&:id)) | ||
98 | + batch_id += 1 | ||
99 | + end | ||
100 | + end | ||
101 | + | ||
98 | def batch_job(class_name, batch_id, record_ids) | 102 | def batch_job(class_name, batch_id, record_ids) |
99 | Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) } | 103 | Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) } |
100 | Searchkick::BulkReindexJob.perform_later( | 104 | Searchkick::BulkReindexJob.perform_later( |
@@ -108,9 +112,5 @@ module Searchkick | @@ -108,9 +112,5 @@ module Searchkick | ||
108 | def batches_key | 112 | def batches_key |
109 | "searchkick:reindex:#{index.name}:batches" | 113 | "searchkick:reindex:#{index.name}:batches" |
110 | end | 114 | end |
111 | - | ||
112 | - def batch_size | ||
113 | - @batch_size ||= index.options[:batch_size] || 1000 | ||
114 | - end | ||
115 | end | 115 | end |
116 | end | 116 | end |