Commit 7af137c46b6a34380e56e363ca096e319698e917
1 parent
0614e889
Exists in
master
and in
21 other branches
Always add callbacks for bulk updates
Showing
2 changed files
with
7 additions
and
9 deletions
Show diff stats
README.md
... | ... | @@ -406,7 +406,7 @@ There are three strategies for keeping the index synced with your database. |
406 | 406 | end |
407 | 407 | ``` |
408 | 408 | |
409 | -For better performance, you can also do bulk updates. [master] | |
409 | +You can also do bulk updates. [master] | |
410 | 410 | |
411 | 411 | ```ruby |
412 | 412 | Searchkick.callbacks(:bulk) do | ... | ... |
lib/searchkick/model.rb
... | ... | @@ -70,14 +70,12 @@ module Searchkick |
70 | 70 | end |
71 | 71 | extend Searchkick::Reindex # legacy for Searchjoy |
72 | 72 | |
73 | - if callbacks | |
74 | - callback_name = callbacks == :async ? :reindex_async : :reindex | |
75 | - if respond_to?(:after_commit) | |
76 | - after_commit callback_name, if: proc { self.class.search_callbacks? } | |
77 | - else | |
78 | - after_save callback_name, if: proc { self.class.search_callbacks? } | |
79 | - after_destroy callback_name, if: proc { self.class.search_callbacks? } | |
80 | - end | |
73 | + callback_name = callbacks == :async ? :reindex_async : :reindex | |
74 | + if respond_to?(:after_commit) | |
75 | + after_commit callback_name, if: proc { self.class.search_callbacks? } | |
76 | + else | |
77 | + after_save callback_name, if: proc { self.class.search_callbacks? } | |
78 | + after_destroy callback_name, if: proc { self.class.search_callbacks? } | |
81 | 79 | end |
82 | 80 | |
83 | 81 | def reindex | ... | ... |