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
dab3ae39
Commit
dab3ae39
authored
May 23, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not paginate pipelines active relation twice
parent
8cca6c83
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
12 deletions
+18
-12
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+1
-4
app/serializers/pipeline_serializer.rb
app/serializers/pipeline_serializer.rb
+6
-7
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+1
-1
spec/lib/gitlab/ci/pipeline/preloader_spec.rb
spec/lib/gitlab/ci/pipeline/preloader_spec.rb
+10
-0
No files found.
app/controllers/projects/pipelines_controller.rb
View file @
dab3ae39
...
...
@@ -15,7 +15,6 @@ class Projects::PipelinesController < Projects::ApplicationController
@pipelines
=
PipelinesFinder
.
new
(
project
,
scope:
@scope
)
.
execute
.
preload
(
:stages
)
.
page
(
params
[
:page
])
.
per
(
30
)
...
...
@@ -24,8 +23,6 @@ class Projects::PipelinesController < Projects::ApplicationController
@finished_count
=
limited_pipelines_count
(
project
,
'finished'
)
@pipelines_count
=
limited_pipelines_count
(
project
)
Gitlab
::
Ci
::
Pipeline
::
Preloader
.
preload!
(
@pipelines
)
respond_to
do
|
format
|
format
.
html
format
.
json
do
...
...
@@ -35,7 +32,7 @@ class Projects::PipelinesController < Projects::ApplicationController
pipelines:
PipelineSerializer
.
new
(
project:
@project
,
current_user:
@current_user
)
.
with_pagination
(
request
,
response
)
.
represent
(
@pipelines
,
disable_coverage:
true
),
.
represent
(
@pipelines
,
disable_coverage:
true
,
preload:
true
),
count:
{
all:
@pipelines_count
,
running:
@running_count
,
...
...
app/serializers/pipeline_serializer.rb
View file @
dab3ae39
class
PipelineSerializer
<
BaseSerializer
include
WithPagination
InvalidResourceError
=
Class
.
new
(
StandardError
)
entity
PipelineDetailsEntity
def
represent
(
resource
,
opts
=
{})
if
resource
.
is_a?
(
ActiveRecord
::
Relation
)
resource
=
resource
.
preload
([
:stages
,
:retryable_builds
,
:cancelable_statuses
,
:trigger_requests
,
...
...
@@ -19,11 +17,12 @@ class PipelineSerializer < BaseSerializer
])
end
if
paginated?
super
(
@paginator
.
paginate
(
resource
),
opts
)
else
super
(
resource
,
opts
)
if
opts
.
delete
(
:preload
)
resource
=
@paginator
.
paginate
(
resource
)
if
paginated?
resource
=
Gitlab
::
Ci
::
Pipeline
::
Preloader
.
preload!
(
resource
)
end
super
(
resource
,
opts
)
end
def
represent_status
(
resource
)
...
...
spec/controllers/projects/pipelines_controller_spec.rb
View file @
dab3ae39
...
...
@@ -36,7 +36,7 @@ describe Projects::PipelinesController do
expect
(
json_response
[
'count'
][
'running'
]).
to
eq
'1'
expect
(
json_response
[
'count'
][
'pending'
]).
to
eq
'1'
expect
(
json_response
[
'count'
][
'finished'
]).
to
eq
'2'
expect
(
queries
.
count
).
to
be
<
32
expect
(
queries
.
count
).
to
be
_within
(
2
).
of
(
29
)
end
it
'does not include coverage data for the pipelines'
do
...
...
spec/lib/gitlab/ci/pipeline/preloader_spec.rb
View file @
dab3ae39
...
...
@@ -18,5 +18,15 @@ describe Gitlab::Ci::Pipeline::Preloader do
described_class
.
preload!
([
pipeline
])
end
it
'returns original collection'
do
allow
(
commit
).
to
receive
(
:lazy_author
)
allow
(
pipeline
).
to
receive
(
:number_of_warnings
)
allow
(
stage
).
to
receive
(
:number_of_warnings
)
pipelines
=
[
pipeline
,
pipeline
]
expect
(
described_class
.
preload!
(
pipelines
)).
to
eq
pipelines
end
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