Class: RSolr::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/patches/db/rsolr.rb

Instance Method Summary collapse

Instance Method Details

#execute_with_profiling(client, request_context) ⇒ Object Also known as: execute



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/patches/db/rsolr.rb', line 3

def execute_with_profiling(client, request_context)
  return execute_without_profiling(client, request_context) unless SqlPatches.should_measure?

  start        = Time.now
  result       = execute_without_profiling(client, request_context)
  elapsed_time = SqlPatches.elapsed_time(start)

  data = "#{request_context[:method].upcase} #{request_context[:uri]}"
  if request_context[:method] == :post and request_context[:data]
    if request_context[:headers].include?("Content-Type") and request_context[:headers]["Content-Type"] == "text/xml"
      # it's xml, unescaping isn't needed
      data << "\n#{request_context[:data]}"
    else
      data << "\n#{Rack::Utils.unescape(request_context[:data])}"
    end
  end
  ::Rack::MiniProfiler.record_sql(data, elapsed_time)

  result
end