Commit 7af137c46b6a34380e56e363ca096e319698e917

Authored by Andrew Kane
1 parent 0614e889

Always add callbacks for bulk updates

Showing 2 changed files with 7 additions and 9 deletions   Show diff stats
@@ -406,7 +406,7 @@ There are three strategies for keeping the index synced with your database. @@ -406,7 +406,7 @@ There are three strategies for keeping the index synced with your database.
406 end 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 ```ruby 411 ```ruby
412 Searchkick.callbacks(:bulk) do 412 Searchkick.callbacks(:bulk) do
lib/searchkick/model.rb
@@ -70,14 +70,12 @@ module Searchkick @@ -70,14 +70,12 @@ module Searchkick
70 end 70 end
71 extend Searchkick::Reindex # legacy for Searchjoy 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 end 79 end
82 80
83 def reindex 81 def reindex