diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 18:08:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 18:08:51 +0000 |
commit | ec18750aa8538712b952b8265581fc3b3e037923 (patch) | |
tree | 7eaf59fe40401415fde3c994bffae0031e2ffd23 /lib/peek | |
parent | 61265b9f01c7db3d4f6e1266d165b1c85be7b9e7 (diff) | |
download | gitlab-ce-ec18750aa8538712b952b8265581fc3b3e037923.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/peek')
-rw-r--r-- | lib/peek/views/active_record.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/peek/views/active_record.rb b/lib/peek/views/active_record.rb index ed3470f81f4..77108bb81ca 100644 --- a/lib/peek/views/active_record.rb +++ b/lib/peek/views/active_record.rb @@ -17,24 +17,35 @@ module Peek } }.freeze + def results + super.merge(calls: detailed_calls) + end + def self.thresholds @thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS) end private + def detailed_calls + "#{calls} (#{cached_calls} cached)" + end + + def cached_calls + detail_store.count { |item| item[:cached] == 'cached' } + end + def setup_subscribers super subscribe('sql.active_record') do |_, start, finish, _, data| if Gitlab::PerformanceBar.enabled_for_request? - unless data[:cached] - detail_store << { - duration: finish - start, - sql: data[:sql].strip, - backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller) - } - end + detail_store << { + duration: finish - start, + sql: data[:sql].strip, + backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller), + cached: data[:cached] ? 'cached' : '' + } end end end |