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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
b376e5c8
Commit
b376e5c8
authored
Sep 12, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix another N+1 query for label priorities
added a QueryRecorder for IssuesController#index.json
parent
53e632cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
app/controllers/boards/issues_controller.rb
app/controllers/boards/issues_controller.rb
+2
-2
app/models/label.rb
app/models/label.rb
+6
-1
spec/controllers/boards/issues_controller_spec.rb
spec/controllers/boards/issues_controller_spec.rb
+11
-0
No files found.
app/controllers/boards/issues_controller.rb
View file @
b376e5c8
...
@@ -12,10 +12,10 @@ module Boards
...
@@ -12,10 +12,10 @@ module Boards
issues
=
issues
.
page
(
params
[
:page
]).
per
(
params
[
:per
]
||
20
)
issues
=
issues
.
page
(
params
[
:page
]).
per
(
params
[
:per
]
||
20
)
make_sure_position_is_set
(
issues
)
make_sure_position_is_set
(
issues
)
issues
=
issues
.
preload
(
:project
,
issues
=
issues
.
preload
(
:project
,
:labels
,
:milestone
,
:milestone
,
:assignees
,
:assignees
,
:notes
=>
[
:award_emoji
,
:author
]
labels:
[
:priorities
],
notes:
[
:award_emoji
,
:author
]
)
)
render
json:
{
render
json:
{
...
...
app/models/label.rb
View file @
b376e5c8
...
@@ -127,7 +127,12 @@ class Label < ActiveRecord::Base
...
@@ -127,7 +127,12 @@ class Label < ActiveRecord::Base
end
end
def
priority
(
project
)
def
priority
(
project
)
priorities
.
find_by
(
project:
project
).
try
(
:priority
)
priority
=
if
priorities
.
loaded?
priorities
.
first
{
|
p
|
p
.
project
==
project
}
else
priorities
.
find_by
(
project:
project
)
end
priority
.
try
(
:priority
)
end
end
def
template?
def
template?
...
...
spec/controllers/boards/issues_controller_spec.rb
View file @
b376e5c8
...
@@ -45,6 +45,17 @@ describe Boards::IssuesController do
...
@@ -45,6 +45,17 @@ describe Boards::IssuesController do
expect
(
parsed_response
.
length
).
to
eq
2
expect
(
parsed_response
.
length
).
to
eq
2
expect
(
development
.
issues
.
map
(
&
:relative_position
)).
not_to
include
(
nil
)
expect
(
development
.
issues
.
map
(
&
:relative_position
)).
not_to
include
(
nil
)
end
end
it
'avoids N+1 database queries'
do
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
])
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
list_issues
(
user:
user
,
board:
board
,
list:
list2
)
}.
count
# 25 issues is bigger than the page size
# the relative position will ignore the `#make_sure_position_set` queries
create_list
(
:labeled_issue
,
25
,
project:
project
,
labels:
[
development
],
assignees:
[
johndoe
],
relative_position:
1
)
expect
{
list_issues
(
user:
user
,
board:
board
,
list:
list2
)
}.
not_to
exceed_query_limit
(
control_count
)
end
end
end
context
'with invalid list id'
do
context
'with invalid list id'
do
...
...
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