Commit ba458115325b90898d0b1c95e6ea545d5faf88d4

Authored by Andrew Kane
1 parent 7290906f

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
1 1 ## 0.8.3 [unreleased]
2 2  
3 3 - Added `timeout` setting
  4 +- Fixed import with no records
4 5  
5 6 ## 0.8.2
6 7  
... ...
lib/searchkick/logging.rb
... ... @@ -38,12 +38,14 @@ module Searchkick
38 38 alias_method_chain :remove, :instrumentation
39 39  
40 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 49 end
48 50 end
49 51 alias_method_chain :import, :instrumentation
... ...