BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9c6c5c79
Commit
9c6c5c79
authored
Oct 14, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Pipeline metrics worker
parent
cb8654e8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
+22
-4
CHANGELOG.md
CHANGELOG.md
+1
-0
pipeline.rb
app/models/ci/pipeline.rb
+6
-4
pipeline_metrics_worker.rb
app/workers/pipeline_metrics_worker.rb
+15
-0
No files found.
CHANGELOG.md
View file @
9c6c5c79
...
@@ -21,6 +21,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -21,6 +21,7 @@ Please view this file on the master branch, on stable branches it's out of date.
-
Change user & group landing page routing from /u/:username to /:username
-
Change user & group landing page routing from /u/:username to /:username
-
Prevent running GfmAutocomplete setup for each diff note !6569
-
Prevent running GfmAutocomplete setup for each diff note !6569
-
Added documentation for .gitattributes files
-
Added documentation for .gitattributes files
-
Move Pipeline Metrics to separate worker
-
AbstractReferenceFilter caches project_refs on RequestStore when active
-
AbstractReferenceFilter caches project_refs on RequestStore when active
-
Replaced the check sign to arrow in the show build view. !6501
-
Replaced the check sign to arrow in the show build view. !6501
-
Add a /wip slash command to toggle the Work In Progress status of a merge request. !6259 (tbalthazar)
-
Add a /wip slash command to toggle the Work In Progress status of a merge request. !6259 (tbalthazar)
...
...
app/models/ci/pipeline.rb
View file @
9c6c5c79
...
@@ -49,6 +49,10 @@ module Ci
...
@@ -49,6 +49,10 @@ module Ci
transition
any
=>
:canceled
transition
any
=>
:canceled
end
end
# IMPORTANT
# Do not add any operations to this state_machine
# Create a separate worker for each new operation
before_transition
[
:created
,
:pending
]
=>
:running
do
|
pipeline
|
before_transition
[
:created
,
:pending
]
=>
:running
do
|
pipeline
|
pipeline
.
started_at
=
Time
.
now
pipeline
.
started_at
=
Time
.
now
end
end
...
@@ -62,13 +66,11 @@ module Ci
...
@@ -62,13 +66,11 @@ module Ci
end
end
after_transition
[
:created
,
:pending
]
=>
:running
do
|
pipeline
|
after_transition
[
:created
,
:pending
]
=>
:running
do
|
pipeline
|
MergeRequest
::
Metrics
.
where
(
merge_request_id:
pipeline
.
merge_requests
.
map
(
&
:id
)).
pipeline
.
run_after_commit
{
PipelineMetricsWorker
.
perform_async
(
id
)
}
update_all
(
latest_build_started_at:
pipeline
.
started_at
,
latest_build_finished_at:
nil
)
end
end
after_transition
any
=>
[
:success
]
do
|
pipeline
|
after_transition
any
=>
[
:success
]
do
|
pipeline
|
MergeRequest
::
Metrics
.
where
(
merge_request_id:
pipeline
.
merge_requests
.
map
(
&
:id
)).
pipeline
.
run_after_commit
{
PipelineMetricsWorker
.
perform_async
(
id
)
}
update_all
(
latest_build_finished_at:
pipeline
.
finished_at
)
end
end
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
pipeline
|
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
pipeline
|
...
...
app/workers/pipeline_metrics_worker.rb
0 → 100644
View file @
9c6c5c79
class
PipelineMetricsWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
pipeline_id
)
Ci
::
Pipeline
.
find_by
(
id:
pipeline_id
).
try
do
|
pipeline
|
merge_requests
=
pipeline
.
merge_requests
.
map
(
&
:id
)
metrics
=
MergeRequest
::
Metrics
.
where
(
merge_request_id:
merge_requests
)
metrics
.
update_all
(
latest_build_started_at:
pipeline
.
started_at
)
if
pipeline
.
active?
metrics
.
update_all
(
latest_build_finished_at:
pipeline
.
finished_at
)
if
pipeline
.
success?
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