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
1 ## 0.8.3 [unreleased] 1 ## 0.8.3 [unreleased]
2 2
3 - Added `timeout` setting 3 - Added `timeout` setting
  4 +- Fixed import with no records
4 5
5 ## 0.8.2 6 ## 0.8.2
6 7
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