Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
32dc1beb
Commit
32dc1beb
authored
Oct 02, 2020
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify logic for showing cached count in performance bar
parent
735db8b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
50 deletions
+1
-50
lib/peek/views/active_record.rb
lib/peek/views/active_record.rb
+1
-15
spec/lib/peek/views/active_record_spec.rb
spec/lib/peek/views/active_record_spec.rb
+0
-35
No files found.
lib/peek/views/active_record.rb
View file @
32dc1beb
...
@@ -5,7 +5,6 @@ module Peek
...
@@ -5,7 +5,6 @@ module Peek
class
ActiveRecord
<
DetailedView
class
ActiveRecord
<
DetailedView
DEFAULT_THRESHOLDS
=
{
DEFAULT_THRESHOLDS
=
{
calls:
100
,
calls:
100
,
cached_calls:
100
,
duration:
3000
,
duration:
3000
,
individual_call:
1000
individual_call:
1000
}.
freeze
}.
freeze
...
@@ -13,7 +12,6 @@ module Peek
...
@@ -13,7 +12,6 @@ module Peek
THRESHOLDS
=
{
THRESHOLDS
=
{
production:
{
production:
{
calls:
100
,
calls:
100
,
cached_calls:
100
,
duration:
15000
,
duration:
15000
,
individual_call:
5000
individual_call:
5000
}
}
...
@@ -30,25 +28,13 @@ module Peek
...
@@ -30,25 +28,13 @@ module Peek
private
private
def
detailed_calls
def
detailed_calls
cached_calls?
?
"
#{
calls
}
|
#{
cached_calls
}
"
:
calls
"
#{
calls
}
(
#{
cached_calls
}
cached)"
end
def
calls
super
-
cached_calls
end
end
def
cached_calls
def
cached_calls
detail_store
.
count
{
|
item
|
item
[
:cached
]
==
'cached'
}
detail_store
.
count
{
|
item
|
item
[
:cached
]
==
'cached'
}
end
end
def
cached_calls?
detail_store
.
any?
{
|
item
|
item
[
:cached
]
==
'cached'
}
end
def
warnings
(
super
+
warning_for
(
cached_calls
,
self
.
class
.
thresholds
[
:cached_calls
],
label:
"
#{
key
}
cached calls"
)).
compact
end
def
setup_subscribers
def
setup_subscribers
super
super
...
...
spec/lib/peek/views/active_record_spec.rb
deleted
100644 → 0
View file @
735db8b7
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Peek
::
Views
::
ActiveRecord
,
:request_store
do
context
'when a class defines thresholds'
do
let
(
:threshold_view
)
do
Class
.
new
(
described_class
)
do
def
self
.
thresholds
{
calls:
1
,
cached_calls:
1
,
duration:
10
,
individual_call:
5
}
end
def
key
'threshold-view'
end
end
.
new
end
context
'when the results exceed the cached calls threshold'
do
before
do
allow
(
threshold_view
)
.
to
receive
(
:detail_store
).
and_return
([{
duration:
0.001
,
cached:
'cached'
},
{
duration:
0.001
,
cached:
'cached'
}])
end
it
'adds a warning to the results key'
do
expect
(
threshold_view
.
results
).
to
include
(
warnings:
[
a_string_matching
(
'threshold-view cached calls'
)])
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment