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
63bd331f
Commit
63bd331f
authored
Jul 28, 2020
by
charlie ablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strongly memoize list
- Add N+1 test
parent
25a98527
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
app/services/boards/issues/list_service.rb
app/services/boards/issues/list_service.rb
+10
-2
spec/support/shared_examples/services/boards/issues_list_service_shared_examples.rb
...es/services/boards/issues_list_service_shared_examples.rb
+9
-0
No files found.
app/services/boards/issues/list_service.rb
View file @
63bd331f
...
@@ -55,9 +55,17 @@ module Boards
...
@@ -55,9 +55,17 @@ module Boards
end
end
def
list
def
list
return
@list
if
defined?
(
@list
)
return
unless
params
.
key?
(
:id
)
@list
=
board
.
lists
.
find
(
params
[
:id
])
if
params
.
key?
(
:id
)
strong_memoize
(
:list
)
do
id
=
params
[
:id
]
if
board
.
lists
.
loaded?
board
.
lists
.
find
{
|
l
|
l
.
id
==
id
}
else
board
.
lists
.
find
(
id
)
end
end
end
end
def
filter_params
def
filter_params
...
...
spec/support/shared_examples/services/boards/issues_list_service_shared_examples.rb
View file @
63bd331f
...
@@ -19,6 +19,15 @@ RSpec.shared_examples 'issues list service' do
...
@@ -19,6 +19,15 @@ RSpec.shared_examples 'issues list service' do
end
end
end
end
it
'avoids N+1'
do
params
=
{
board_id:
board
.
id
}
control
=
ActiveRecord
::
QueryRecorder
.
new
{
described_class
.
new
(
parent
,
user
,
params
).
execute
}
create
(
:list
,
board:
board
)
expect
{
described_class
.
new
(
parent
,
user
,
params
).
execute
}.
not_to
exceed_query_limit
(
control
)
end
context
'issues are ordered by priority'
do
context
'issues are ordered by priority'
do
it
'returns opened issues when list_id is missing'
do
it
'returns opened issues when list_id is missing'
do
params
=
{
board_id:
board
.
id
}
params
=
{
board_id:
board
.
id
}
...
...
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