Commit 04af5ba2883521c1c64093a015c5f7e46aaeb41a

Authored by Andrew Kane
1 parent 383550e7

Use one method for simplicity

Showing 1 changed file with 4 additions and 6 deletions   Show diff stats
lib/searchkick/logging.rb
@@ -20,7 +20,7 @@ module Searchkick @@ -20,7 +20,7 @@ module Searchkick
20 name: "#{record.searchkick_klass.name} Store", 20 name: "#{record.searchkick_klass.name} Store",
21 id: search_id(record) 21 id: search_id(record)
22 } 22 }
23 - ActiveSupport::Notifications.instrument("store.searchkick", event) do 23 + ActiveSupport::Notifications.instrument("request.searchkick", event) do
24 store_without_instrumentation(record) 24 store_without_instrumentation(record)
25 end 25 end
26 end 26 end
@@ -31,7 +31,7 @@ module Searchkick @@ -31,7 +31,7 @@ module Searchkick
31 name: "#{record.searchkick_klass.name} Remove", 31 name: "#{record.searchkick_klass.name} Remove",
32 id: search_id(record) 32 id: search_id(record)
33 } 33 }
34 - ActiveSupport::Notifications.instrument("remove.searchkick", event) do 34 + ActiveSupport::Notifications.instrument("request.searchkick", event) do
35 remove_without_instrumentation(record) 35 remove_without_instrumentation(record)
36 end 36 end
37 end 37 end
@@ -42,7 +42,7 @@ module Searchkick @@ -42,7 +42,7 @@ module Searchkick
42 name: "#{records.first.searchkick_klass.name} Import", 42 name: "#{records.first.searchkick_klass.name} Import",
43 count: records.size 43 count: records.size
44 } 44 }
45 - ActiveSupport::Notifications.instrument("import.searchkick", event) do 45 + ActiveSupport::Notifications.instrument("request.searchkick", event) do
46 import_without_instrumentation(records) 46 import_without_instrumentation(records)
47 end 47 end
48 end 48 end
@@ -78,7 +78,7 @@ module Searchkick @@ -78,7 +78,7 @@ module Searchkick
78 debug " #{color(name, YELLOW, true)} curl #{host[:protocol]}://#{host[:host]}:#{host[:port]}/#{CGI.escape(index)}#{type ? "/#{type.map{|t| CGI.escape(t) }.join(",")}" : ""}/_search?pretty -d '#{payload[:query][:body].to_json}'" 78 debug " #{color(name, YELLOW, true)} curl #{host[:protocol]}://#{host[:host]}:#{host[:port]}/#{CGI.escape(index)}#{type ? "/#{type.map{|t| CGI.escape(t) }.join(",")}" : ""}/_search?pretty -d '#{payload[:query][:body].to_json}'"
79 end 79 end
80 80
81 - def store(event) 81 + def request(event)
82 self.class.runtime += event.duration 82 self.class.runtime += event.duration
83 return unless logger.debug? 83 return unless logger.debug?
84 84
@@ -87,8 +87,6 @@ module Searchkick @@ -87,8 +87,6 @@ module Searchkick
87 87
88 debug " #{color(name, YELLOW, true)} #{payload.except(:name).to_json}" 88 debug " #{color(name, YELLOW, true)} #{payload.except(:name).to_json}"
89 end 89 end
90 - alias_method :remove, :store  
91 - alias_method :import, :store  
92 end 90 end
93 91
94 # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/controller_runtime.rb 92 # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/controller_runtime.rb