Commit ba458115325b90898d0b1c95e6ea545d5faf88d4
1 parent
7290906f
Exists in
master
and in
21 other branches
Fixed import with no records - fixes #279 and fixes #282
Showing
2 changed files
with
9 additions
and
6 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/logging.rb
@@ -38,12 +38,14 @@ module Searchkick | @@ -38,12 +38,14 @@ module Searchkick | ||
38 | alias_method_chain :remove, :instrumentation | 38 | alias_method_chain :remove, :instrumentation |
39 | 39 | ||
40 | def import_with_instrumentation(records) | 40 | def import_with_instrumentation(records) |
41 | - event = { | ||
42 | - name: "#{records.first.searchkick_klass.name} Import", | ||
43 | - count: records.size | ||
44 | - } | ||
45 | - ActiveSupport::Notifications.instrument("request.searchkick", event) do | ||
46 | - import_without_instrumentation(records) | 41 | + if records.any? |
42 | + event = { | ||
43 | + name: "#{records.first.searchkick_klass.name} Import", | ||
44 | + count: records.size | ||
45 | + } | ||
46 | + ActiveSupport::Notifications.instrument("request.searchkick", event) do | ||
47 | + import_without_instrumentation(records) | ||
48 | + end | ||
47 | end | 49 | end |
48 | end | 50 | end |
49 | alias_method_chain :import, :instrumentation | 51 | alias_method_chain :import, :instrumentation |