Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-07-24 17:42:45 +0300
committerStan Hu <stanhu@gmail.com>2019-07-24 18:57:42 +0300
commitd7eadcc0f30d3bd005f9dfb160dd0a460b3a8f56 (patch)
tree190331c52fcdfd555367ebb729098db3df2b4fa0 /lib/peek/views/redis_detailed.rb
parentc02c83fa9b63601a0a4cb8ed78311d9461e70e35 (diff)
Use a base class for Peek views
Introduce a `DetailedView` base class, which is inherited by the Gitaly, Redis, and Rugged views. This reduces code duplication.
Diffstat (limited to 'lib/peek/views/redis_detailed.rb')
-rw-r--r--lib/peek/views/redis_detailed.rb23
1 files changed, 2 insertions, 21 deletions
diff --git a/lib/peek/views/redis_detailed.rb b/lib/peek/views/redis_detailed.rb
index 12760c9b75e..c61a1e91282 100644
--- a/lib/peek/views/redis_detailed.rb
+++ b/lib/peek/views/redis_detailed.rb
@@ -35,36 +35,19 @@ end
module Peek
module Views
- class RedisDetailed < View
+ class RedisDetailed < DetailedView
REDACTED_MARKER = "<redacted>"
def key
'redis'
end
- def results
- {
- calls: calls,
- duration: formatted_duration,
- details: details
- }
- end
-
def detail_store
::Gitlab::SafeRequestStore['redis_call_details'] ||= []
end
private
- def formatted_duration
- ms = duration * 1000
- if ms >= 1000
- "%.2fms" % ms
- else
- "%.0fms" % ms
- end
- end
-
def duration
detail_store.map { |entry| entry[:duration] }.sum # rubocop:disable CodeReuse/ActiveRecord
end
@@ -73,10 +56,8 @@ module Peek
detail_store.count
end
- def details
+ def call_details
detail_store
- .sort { |a, b| b[:duration] <=> a[:duration] }
- .map(&method(:format_call_details))
end
def format_call_details(call)