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
1bb21af9
Commit
1bb21af9
authored
Feb 26, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
2d59e31b
3ae5e475
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
3 deletions
+26
-3
app/finders/admin/runners_finder.rb
app/finders/admin/runners_finder.rb
+1
-1
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-0
app/views/admin/runners/_runner.html.haml
app/views/admin/runners/_runner.html.haml
+1
-1
changelogs/unreleased/sh-remove-nplusone-admin-runners-tags.yml
...logs/unreleased/sh-remove-nplusone-admin-runners-tags.yml
+5
-0
spec/controllers/admin/runners_controller_spec.rb
spec/controllers/admin/runners_controller_spec.rb
+18
-1
No files found.
app/finders/admin/runners_finder.rb
View file @
1bb21af9
...
...
@@ -14,7 +14,7 @@ class Admin::RunnersFinder < UnionFinder
sort!
paginate!
@runners
@runners
.
with_tags
end
def
sort_key
...
...
app/models/ci/runner.rb
View file @
1bb21af9
...
...
@@ -97,6 +97,7 @@ module Ci
scope
:order_contacted_at_asc
,
->
{
order
(
contacted_at: :asc
)
}
scope
:order_created_at_desc
,
->
{
order
(
created_at: :desc
)
}
scope
:with_tags
,
->
{
preload
(
:tags
)
}
validate
:tag_constraints
validates
:access_level
,
presence:
true
...
...
app/views/admin/runners/_runner.html.haml
View file @
1bb21af9
...
...
@@ -49,7 +49,7 @@
.table-section.section-10.section-wrap
.table-mobile-header
{
role:
'rowheader'
}=
_
(
'Tags'
)
.table-mobile-content
-
runner
.
tag
_list
.
sort
.
each
do
|
tag
|
-
runner
.
tag
s
.
map
(
&
:name
)
.
sort
.
each
do
|
tag
|
%span
.badge.badge-primary
=
tag
...
...
changelogs/unreleased/sh-remove-nplusone-admin-runners-tags.yml
0 → 100644
View file @
1bb21af9
---
title
:
Remove N+1 query for tags in /admin/runners page
merge_request
:
25572
author
:
type
:
performance
spec/controllers/admin/runners_controller_spec.rb
View file @
1bb21af9
require
'spec_helper'
describe
Admin
::
RunnersController
do
let
(
:runner
)
{
create
(
:ci_runner
)
}
let
!
(
:runner
)
{
create
(
:ci_runner
)
}
before
do
sign_in
(
create
(
:admin
))
end
describe
'#index'
do
render_views
it
'lists all runners'
do
get
:index
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it
'avoids N+1 queries'
,
:request_store
do
get
:index
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
get
:index
}.
count
create
(
:ci_runner
,
:tagged_only
)
# There is still an N+1 query for `runner.builds.count`
expect
{
get
:index
}.
not_to
exceed_query_limit
(
control_count
+
1
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
body
).
to
have_content
(
'tag1'
)
expect
(
response
.
body
).
to
have_content
(
'tag2'
)
end
end
describe
'#show'
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