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
Boxiang Sun
gitlab-ce
Commits
16a2eba5
Commit
16a2eba5
authored
Apr 07, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Count number of queries
parent
37e7fe2c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
1 deletion
+43
-1
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+5
-0
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+1
-1
changelogs/unreleased/optimise-builds-view.yml
changelogs/unreleased/optimise-builds-view.yml
+4
-0
spec/controllers/projects/builds_controller_spec.rb
spec/controllers/projects/builds_controller_spec.rb
+33
-0
No files found.
app/controllers/projects/builds_controller.rb
View file @
16a2eba5
...
@@ -19,6 +19,11 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -19,6 +19,11 @@ class Projects::BuildsController < Projects::ApplicationController
else
else
@builds
@builds
end
end
@builds
=
@builds
.
includes
([
{
pipeline: :project
},
:project
,
:tags
])
@builds
=
@builds
.
page
(
params
[
:page
]).
per
(
30
)
@builds
=
@builds
.
page
(
params
[
:page
]).
per
(
30
)
end
end
...
...
app/models/concerns/has_status.rb
View file @
16a2eba5
...
@@ -68,7 +68,7 @@ module HasStatus
...
@@ -68,7 +68,7 @@ module HasStatus
end
end
scope
:created
,
->
{
where
(
status:
'created'
)
}
scope
:created
,
->
{
where
(
status:
'created'
)
}
scope
:relevant
,
->
{
where
.
not
(
status:
'created'
)
}
scope
:relevant
,
->
{
where
(
status:
AVAILABLE_STATUSES
-
[
'created'
]
)
}
scope
:running
,
->
{
where
(
status:
'running'
)
}
scope
:running
,
->
{
where
(
status:
'running'
)
}
scope
:pending
,
->
{
where
(
status:
'pending'
)
}
scope
:pending
,
->
{
where
(
status:
'pending'
)
}
scope
:success
,
->
{
where
(
status:
'success'
)
}
scope
:success
,
->
{
where
(
status:
'success'
)
}
...
...
changelogs/unreleased/optimise-builds-view.yml
0 → 100644
View file @
16a2eba5
---
title
:
Optimise builds endpoint
merge_request
:
author
:
spec/controllers/projects/builds_controller_spec.rb
View file @
16a2eba5
...
@@ -10,6 +10,39 @@ describe Projects::BuildsController do
...
@@ -10,6 +10,39 @@ describe Projects::BuildsController do
sign_in
(
user
)
sign_in
(
user
)
end
end
describe
'GET index'
do
context
'number of queries'
do
before
do
Ci
::
Build
::
AVAILABLE_STATUSES
.
each
do
|
status
|
create_build
(
status
,
status
)
end
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
def
render
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
end
it
"verifies number of queries"
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
render
}
expect
(
recorded
.
count
).
to
be_within
(
5
).
of
(
8
)
end
def
create_build
(
name
,
status
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
)
create
(
:ci_build
,
:tags
,
:triggered
,
:artifacts
,
pipeline:
pipeline
,
name:
name
,
status:
status
)
end
end
end
describe
'GET status.json'
do
describe
'GET status.json'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
...
...
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