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
a241581c
Commit
a241581c
authored
Jul 14, 2020
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for cached queries
- Add changelog
parent
76f8c168
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
changelogs/unreleased/217580-improve-performance-of-blob.yml
changelogs/unreleased/217580-improve-performance-of-blob.yml
+5
-0
spec/lib/banzai/filter/label_reference_filter_spec.rb
spec/lib/banzai/filter/label_reference_filter_spec.rb
+13
-0
spec/lib/banzai/reference_parser/snippet_parser_spec.rb
spec/lib/banzai/reference_parser/snippet_parser_spec.rb
+11
-0
No files found.
changelogs/unreleased/217580-improve-performance-of-blob.yml
0 → 100644
View file @
a241581c
---
title
:
Reduce 'cached' query calls for Banzai
merge_request
:
36735
author
:
type
:
performance
spec/lib/banzai/filter/label_reference_filter_spec.rb
View file @
a241581c
...
...
@@ -31,6 +31,19 @@ RSpec.describe Banzai::Filter::LabelReferenceFilter do
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'class'
)).
to
eq
'gfm gfm-label has-tooltip gl-link gl-label-link'
end
it
'avoids N+1 cached queries'
,
:use_sql_query_cache
,
:request_store
do
# Run this once to establish a baseline
reference_filter
(
"Label
#{
reference
}
"
)
control_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
do
reference_filter
(
"Label
#{
reference
}
"
)
end
labels_markdown
=
Array
.
new
(
10
,
"Label
#{
reference
}
"
).
join
(
'\n'
)
expect
{
reference_filter
(
labels_markdown
)
}.
not_to
exceed_all_query_limit
(
control_count
.
count
)
end
it
'includes a data-project attribute'
do
doc
=
reference_filter
(
"Label
#{
reference
}
"
)
link
=
doc
.
css
(
'a'
).
first
...
...
spec/lib/banzai/reference_parser/snippet_parser_spec.rb
View file @
a241581c
...
...
@@ -33,6 +33,17 @@ RSpec.describe Banzai::ReferenceParser::SnippetParser do
project
.
project_feature
.
update_attribute
(
:snippets_access_level
,
ProjectFeature
::
ENABLED
)
end
it
'avoids N+1 cached queries'
,
:use_sql_query_cache
do
# Run this once to establish a baseline
visible_references
(
:public
)
control_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
do
subject
.
nodes_visible_to_user
(
user
,
[
link
])
end
expect
{
subject
.
nodes_visible_to_user
(
user
,
Array
.
new
(
10
,
link
))
}.
not_to
exceed_all_query_limit
(
control_count
.
count
)
end
it
'creates a reference for guest for a public snippet'
do
expect
(
visible_references
(
:public
)).
to
eq
([
link
])
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