Commit 73310a4dd1362d63813a3da50ee7d39bc4d1b0f8
1 parent
16e61e17
Exists in
master
and in
2 other branches
Fixed notification messages [skip ci]
Showing
2 changed files
with
6 additions
and
3 deletions
Show diff stats
lib/searchkick.rb
@@ -200,7 +200,8 @@ module Searchkick | @@ -200,7 +200,8 @@ module Searchkick | ||
200 | end | 200 | end |
201 | end | 201 | end |
202 | 202 | ||
203 | - def self.callbacks(value = nil) | 203 | + # message is private |
204 | + def self.callbacks(value = nil, message: "Bulk") | ||
204 | if block_given? | 205 | if block_given? |
205 | previous_value = callbacks_value | 206 | previous_value = callbacks_value |
206 | begin | 207 | begin |
@@ -208,7 +209,7 @@ module Searchkick | @@ -208,7 +209,7 @@ module Searchkick | ||
208 | result = yield | 209 | result = yield |
209 | if callbacks_value == :bulk | 210 | if callbacks_value == :bulk |
210 | event = { | 211 | event = { |
211 | - name: "Bulk", | 212 | + name: message, |
212 | count: indexer.queued_items.size | 213 | count: indexer.queued_items.size |
213 | } | 214 | } |
214 | ActiveSupport::Notifications.instrument("request.searchkick", event) do | 215 | ActiveSupport::Notifications.instrument("request.searchkick", event) do |
lib/searchkick/bulk_indexer.rb
@@ -106,8 +106,10 @@ module Searchkick | @@ -106,8 +106,10 @@ module Searchkick | ||
106 | 106 | ||
107 | # import in single request with retries | 107 | # import in single request with retries |
108 | def import_inline(index_records, delete_records, method_name:) | 108 | def import_inline(index_records, delete_records, method_name:) |
109 | + action = method_name ? "Update" : "Import" | ||
110 | + name = (index_records.first || delete_records.first).searchkick_klass.name | ||
109 | with_retries do | 111 | with_retries do |
110 | - Searchkick.callbacks(:bulk) do | 112 | + Searchkick.callbacks(:bulk, message: "#{name} #{action}") do |
111 | if index_records.any? | 113 | if index_records.any? |
112 | if method_name | 114 | if method_name |
113 | index.bulk_update(index_records, method_name) | 115 | index.bulk_update(index_records, method_name) |