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
a7d1be39
Commit
a7d1be39
authored
May 11, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for N+1 in EpicReferenceFilter
parent
e9d46397
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
ee/spec/lib/banzai/filter/references/epic_reference_filter_spec.rb
...ib/banzai/filter/references/epic_reference_filter_spec.rb
+30
-0
No files found.
ee/spec/lib/banzai/filter/references/epic_reference_filter_spec.rb
View file @
a7d1be39
...
...
@@ -261,4 +261,34 @@ RSpec.describe Banzai::Filter::References::EpicReferenceFilter do
expect
(
doc
(
text
).
css
(
'a'
).
first
.
attr
(
'class'
)).
to
eq
(
'gfm gfm-epic has-tooltip'
)
end
end
context
'checking N+1'
do
let
(
:epic2
)
{
create
(
:epic
,
group:
another_group
)
}
let
(
:project
)
{
create
(
:project
,
group:
another_group
)
}
let
(
:full_ref_text
)
{
"
#{
epic
.
group
.
full_path
}
&
#{
epic
.
iid
}
"
}
let
(
:context
)
{
{
project:
nil
,
group:
group
}
}
it
'does not have N+1 per multiple references per group'
,
:use_sql_query_cache
do
markdown
=
"
#{
epic
.
to_reference
}
&9999990"
# warm up
reference_filter
(
markdown
,
context
)
control_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
do
reference_filter
(
markdown
,
context
)
end
.
count
markdown
=
"
#{
epic
.
to_reference
}
#{
epic
.
group
.
full_path
}
&9999991
#{
epic
.
group
.
full_path
}
&9999992 &9999993
#{
epic2
.
to_reference
(
group
)
}
#{
epic2
.
group
.
full_path
}
&9999991 something/cool&12"
# Since we're not batching queries across groups,
# we have to account for that.
# 1 for both groups, 1 for epics in each group == 3
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/330359
max_count
=
control_count
+
1
expect
do
reference_filter
(
markdown
,
context
)
end
.
not_to
exceed_all_query_limit
(
max_count
)
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