Module: Searchkick::IndexWithInstrumentation

Defined in:
lib/searchkick/logging.rb

Instance Method Summary collapse

Instance Method Details

#import(records) ⇒ Object


48
49
50
51
52
53
54
55
56
57
58
# File 'lib/searchkick/logging.rb', line 48

def import(records)
  if records.any?
    event = {
      name: "#{records.first.searchkick_klass.name} Import",
      count: records.size
    }
    ActiveSupport::Notifications.instrument("request.searchkick", event) do
      super(records)
    end
  end
end

#remove(record) ⇒ Object


33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/searchkick/logging.rb', line 33

def remove(record)
  name = record && record.searchkick_klass ? "#{record.searchkick_klass.name} Remove" : "Remove"
  event = {
    name: name,
    id: search_id(record)
  }
  if Searchkick.callbacks_value == :bulk
    super
  else
    ActiveSupport::Notifications.instrument("request.searchkick", event) do
      super
    end
  end
end

#store(record) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/searchkick/logging.rb', line 19

def store(record)
  event = {
    name: "#{record.searchkick_klass.name} Store",
    id: search_id(record)
  }
  if Searchkick.callbacks_value == :bulk
    super
  else
    ActiveSupport::Notifications.instrument("request.searchkick", event) do
      super
    end
  end
end