Class: RSolr::Connection

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

Instance Method Summary collapse

Instance Method Details

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



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/patches/sql_patches.rb', line 199

def execute_with_profiling(client, request_context)
  current = ::Rack::MiniProfiler.current
  return execute_without_profiling(client, request_context) unless current && current.measure

  start = Time.now
  result = execute_without_profiling(client, request_context)
  elapsed_time = ((Time.now - start).to_f * 1000).round(1)

  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