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
2791226c
Commit
2791226c
authored
Dec 01, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove support from incremental pipeline updates
parent
57b19769
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
60 deletions
+9
-60
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+1
-2
app/serializers/pipeline_entity.rb
app/serializers/pipeline_entity.rb
+7
-31
app/serializers/pipeline_serializer.rb
app/serializers/pipeline_serializer.rb
+0
-5
spec/serializers/pipeline_serializer_spec.rb
spec/serializers/pipeline_serializer_spec.rb
+1
-22
No files found.
app/controllers/projects/pipelines_controller.rb
View file @
2791226c
...
...
@@ -11,7 +11,6 @@ class Projects::PipelinesController < Projects::ApplicationController
@running_or_pending_count
=
PipelinesFinder
.
new
(
project
).
execute
(
scope:
'running'
).
count
@pipelines_count
=
PipelinesFinder
.
new
(
project
).
execute
.
count
@last_updated
=
params
[
:updated_at
]
respond_to
do
|
format
|
format
.
html
...
...
@@ -19,7 +18,7 @@ class Projects::PipelinesController < Projects::ApplicationController
render
json:
{
pipelines:
PipelineSerializer
.
new
(
project:
@project
,
user:
@current_user
)
.
incremental
(
@pipelines
,
@last_updated
),
.
represent
(
@pipelines
),
updated_at:
Time
.
now
.
utc
,
count:
{
all:
@pipelines_count
,
...
...
app/serializers/pipeline_entity.rb
View file @
2791226c
...
...
@@ -2,7 +2,7 @@ class PipelineEntity < Grape::Entity
include
RequestAwareEntity
expose
:id
expose
:user
,
if:
proc
{
created_exposure?
},
using:
UserEntity
expose
:user
,
using:
UserEntity
expose
:url
do
|
pipeline
|
namespace_project_pipeline_path
(
...
...
@@ -11,7 +11,7 @@ class PipelineEntity < Grape::Entity
pipeline
)
end
expose
:details
,
if:
proc
{
updated_exposure?
}
do
expose
:details
do
expose
:status
expose
:duration
expose
:finished_at
...
...
@@ -20,7 +20,7 @@ class PipelineEntity < Grape::Entity
expose
:manual_actions
,
using:
PipelineActionEntity
end
expose
:flags
,
if:
proc
{
created_exposure?
}
do
expose
:flags
do
expose
:latest?
,
as: :latest
expose
:triggered?
,
as: :triggered
...
...
@@ -33,7 +33,7 @@ class PipelineEntity < Grape::Entity
end
end
expose
:ref
,
if:
proc
{
updated_exposure?
}
do
expose
:ref
do
expose
:name
do
|
pipeline
|
pipeline
.
ref
end
...
...
@@ -48,16 +48,16 @@ class PipelineEntity < Grape::Entity
expose
:tag?
end
expose
:commit
,
if:
proc
{
created_exposure?
},
using:
CommitEntity
expose
:commit
,
using:
CommitEntity
expose
:retry_url
,
if:
proc
{
updated_exposure?
}
do
|
pipeline
|
expose
:retry_url
do
|
pipeline
|
can?
(
request
.
user
,
:update_pipeline
,
pipeline
.
project
)
&&
pipeline
.
retryable?
&&
retry_namespace_project_pipeline_path
(
pipeline
.
project
.
namespace
,
pipeline
.
project
,
pipeline
.
id
)
end
expose
:cancel_url
,
if:
proc
{
updated_exposure?
}
do
|
pipeline
|
expose
:cancel_url
do
|
pipeline
|
can?
(
request
.
user
,
:update_pipeline
,
pipeline
.
project
)
&&
pipeline
.
cancelable?
&&
cancel_namespace_project_pipeline_path
(
pipeline
.
project
.
namespace
,
...
...
@@ -65,28 +65,4 @@ class PipelineEntity < Grape::Entity
end
expose
:created_at
,
:updated_at
def
created_exposure?
!
incremental?
||
created?
end
def
updated_exposure?
!
incremental?
||
updated?
end
def
incremental?
options
[
:incremental
]
&&
last_updated
end
def
last_updated
options
.
fetch
(
:last_updated
)
end
def
updated?
@object
.
updated_at
>
last_updated
end
def
created?
@object
.
created_at
>
last_updated
end
end
app/serializers/pipeline_serializer.rb
View file @
2791226c
class
PipelineSerializer
<
BaseSerializer
entity
PipelineEntity
def
incremental
(
resource
,
last_updated
)
represent
(
resource
,
incremental:
true
,
last_updated:
last_updated
)
end
end
spec/serializers/pipeline_serializer_spec.rb
View file @
2791226c
...
...
@@ -11,26 +11,5 @@ describe PipelineSerializer do
let
(
:user
)
{
create
(
:user
)
}
context
'when using incremental serializer'
do
let
(
:json
)
do
serializer
.
incremental
(
pipelines
,
time
).
as_json
end
context
'when pipeline has been already updated'
do
let
(
:time
)
{
Time
.
now
}
it
'exposes only minimal information'
do
expect
(
json
.
first
.
keys
).
to
contain_exactly
(
:id
,
:url
)
expect
(
json
.
second
.
keys
).
to
contain_exactly
(
:id
,
:url
)
end
end
context
'when pipeline updated in the meantime'
do
let
(
:time
)
{
Time
.
now
-
10
.
minutes
}
it
'exposes new data incrementally'
do
expect
(
json
.
first
.
keys
.
count
).
to
eq
9
end
end
end
# TODO add some tests here.
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