diff options
Diffstat (limited to 'lib/peek/views/active_record.rb')
-rw-r--r-- | lib/peek/views/active_record.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/peek/views/active_record.rb b/lib/peek/views/active_record.rb index 523e673e9e1..4040bed50a9 100644 --- a/lib/peek/views/active_record.rb +++ b/lib/peek/views/active_record.rb @@ -17,22 +17,32 @@ module Peek } }.freeze - def results - super.merge(calls: detailed_calls) - end - def self.thresholds @thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS) end + def results + super.merge(summary: summary) + end + private - def detailed_calls - "#{calls} (#{cached_calls} cached)" + def summary + detail_store.each_with_object({}) do |item, count| + count_summary(item, count) + end end - def cached_calls - detail_store.count { |item| item[:cached] == 'cached' } + def count_summary(item, count) + if item[:cached].present? + count[item[:cached]] ||= 0 + count[item[:cached]] += 1 + end + + if item[:transaction].present? + count[item[:transaction]] ||= 0 + count[item[:transaction]] += 1 + end end def setup_subscribers @@ -45,10 +55,12 @@ module Peek def generate_detail(start, finish, data) { + start: start, duration: finish - start, sql: data[:sql].strip, backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller), - cached: data[:cached] ? 'cached' : '' + cached: data[:cached] ? 'Cached' : '', + transaction: data[:connection].transaction_open? ? 'In a transaction' : '' } end end |