lib/searchkick/logging.rb in searchkick-2.1.0 vs lib/searchkick/logging.rb in searchkick-2.1.1

- old
+ new

@@ -43,32 +43,49 @@ super end end end - def import(records) + def update_record(record, method_name) + event = { + name: "#{record.searchkick_klass.name} Update", + id: search_id(record) + } + if Searchkick.callbacks_value == :bulk + super + else + ActiveSupport::Notifications.instrument("request.searchkick", event) do + super + end + end + end + + def bulk_index(records) if records.any? event = { name: "#{records.first.searchkick_klass.name} Import", count: records.size } + event[:id] = search_id(records.first) if records.size == 1 if Searchkick.callbacks_value == :bulk super else ActiveSupport::Notifications.instrument("request.searchkick", event) do super end end end end + alias_method :import, :bulk_index def bulk_update(records, *args) if records.any? event = { name: "#{records.first.searchkick_klass.name} Update", count: records.size } + event[:id] = search_id(records.first) if records.size == 1 if Searchkick.callbacks_value == :bulk super else ActiveSupport::Notifications.instrument("request.searchkick", event) do super @@ -81,9 +98,10 @@ if records.any? event = { name: "#{records.first.searchkick_klass.name} Delete", count: records.size } + event[:id] = search_id(records.first) if records.size == 1 if Searchkick.callbacks_value == :bulk super else ActiveSupport::Notifications.instrument("request.searchkick", event) do super