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
50dc6150
Commit
50dc6150
authored
Nov 11, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix slow reference parser test case
parent
2e271e79
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
lib/banzai/reference_parser/base_parser.rb
lib/banzai/reference_parser/base_parser.rb
+4
-1
spec/lib/banzai/reference_parser/base_parser_spec.rb
spec/lib/banzai/reference_parser/base_parser_spec.rb
+3
-0
No files found.
lib/banzai/reference_parser/base_parser.rb
View file @
50dc6150
...
...
@@ -178,7 +178,10 @@ module Banzai
collection
.
where
(
id:
to_query
).
each
{
|
row
|
cache
[
row
.
id
]
=
row
}
end
ids
.
uniq
.
map
{
|
id
|
cache
[
id
]
}.
compact
ids
.
each_with_object
([])
do
|
id
,
array
|
row
=
cache
[
id
]
array
<<
row
if
row
end
else
collection
.
where
(
id:
ids
)
end
...
...
spec/lib/banzai/reference_parser/base_parser_spec.rb
View file @
50dc6150
...
...
@@ -323,6 +323,9 @@ RSpec.describe Banzai::ReferenceParser::BaseParser do
it
'will not overflow the stack'
do
ids
=
1
.
upto
(
1_000_000
).
to_a
# Avoid executing a large, unnecessary SQL query
expect
(
User
).
to
receive
(
:where
).
with
(
id:
ids
).
and_return
(
User
.
none
)
expect
{
subject
.
collection_objects_for_ids
(
User
,
ids
)
}.
not_to
raise_error
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