Module: ActiveRecordQueryCounter::ConnectionAdapterExtension
- Defined in:
- lib/active_record_query_counter/connection_adapter_extension.rb
Overview
Module to prepend to the connection adapter to inject the counting behavior.
Instance Method Summary collapse
Instance Method Details
#exec_query(sql, name = nil, binds = [], *args, **kwargs) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/active_record_query_counter/connection_adapter_extension.rb', line 6 def exec_query(sql, name = nil, binds = [], *args, **kwargs) start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = super if result.is_a?(ActiveRecord::Result) end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) ActiveRecordQueryCounter.add_query(sql, name, binds, result.length, start_time, end_time) end result end |