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
53d571fa
Commit
53d571fa
authored
Apr 16, 2020
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure embeds cache correctly
parent
e9af13e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
15 deletions
+40
-15
app/services/metrics/dashboard/transient_embed_service.rb
app/services/metrics/dashboard/transient_embed_service.rb
+5
-0
spec/services/metrics/dashboard/transient_embed_service_spec.rb
...ervices/metrics/dashboard/transient_embed_service_spec.rb
+35
-15
No files found.
app/services/metrics/dashboard/transient_embed_service.rb
View file @
53d571fa
...
...
@@ -30,6 +30,11 @@ module Metrics
def
sequence
[
STAGES
::
EndpointInserter
]
end
override
:identifiers
def
identifiers
Digest
::
SHA256
.
hexdigest
(
params
[
:embed_json
])
end
end
end
end
spec/services/metrics/dashboard/transient_embed_service_spec.rb
View file @
53d571fa
...
...
@@ -38,21 +38,7 @@ describe Metrics::Dashboard::TransientEmbedService, :use_clean_rails_memory_stor
end
describe
'#get_dashboard'
do
let
(
:embed_json
)
do
{
panel_groups:
[{
panels:
[{
type:
'line-graph'
,
title:
'title'
,
y_label:
'y_label'
,
metrics:
[{
query_range:
'up'
,
label:
'y_label'
}]
}]
}]
}.
to_json
end
let
(
:embed_json
)
{
get_embed_json
}
let
(
:service_params
)
{
[
project
,
user
,
{
environment:
environment
,
embedded:
'true'
,
embed_json:
embed_json
}]
}
let
(
:service_call
)
{
described_class
.
new
(
*
service_params
).
get_dashboard
}
...
...
@@ -68,5 +54,39 @@ describe Metrics::Dashboard::TransientEmbedService, :use_clean_rails_memory_stor
described_class
.
new
(
*
service_params
).
get_dashboard
described_class
.
new
(
*
service_params
).
get_dashboard
end
it
'caches unique requests separately'
do
alt_embed_json
=
get_embed_json
(
'area-chart'
)
alt_service_params
=
[
project
,
user
,
{
environment:
environment
,
embedded:
'true'
,
embed_json:
alt_embed_json
}]
embed
=
described_class
.
new
(
*
service_params
).
get_dashboard
alt_embed
=
described_class
.
new
(
*
alt_service_params
).
get_dashboard
expect
(
embed
).
not_to
eq
(
alt_embed
)
expect
(
get_type_for_embed
(
embed
)).
to
eq
(
'line-graph'
)
expect
(
get_type_for_embed
(
alt_embed
)).
to
eq
(
'area-chart'
)
end
private
def
get_embed_json
(
type
=
'line-graph'
)
{
panel_groups:
[{
panels:
[{
type:
type
,
title:
'title'
,
y_label:
'y_label'
,
metrics:
[{
query_range:
'up'
,
label:
'y_label'
}]
}]
}]
}.
to_json
end
def
get_type_for_embed
(
embed
)
embed
[
:dashboard
][
:panel_groups
][
0
][
:panels
][
0
][
:type
]
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