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
7aaed299
Commit
7aaed299
authored
Sep 02, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just sum all the queuing time, indication for needing more runners
parent
8d96062f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
lib/gitlab/ci/pipeline_duration.rb
lib/gitlab/ci/pipeline_duration.rb
+7
-6
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+1
-1
No files found.
lib/gitlab/ci/pipeline_duration.rb
View file @
7aaed299
...
@@ -107,19 +107,20 @@ module Gitlab
...
@@ -107,19 +107,20 @@ module Gitlab
end
end
def
self
.
from_pipeline
(
pipeline
)
def
self
.
from_pipeline
(
pipeline
)
now
=
Time
.
now
status
=
%w[success failed running canceled]
status
=
%w[success failed running canceled]
builds
=
pipeline
.
builds
.
latest
.
where
(
status:
status
)
builds
=
pipeline
.
builds
.
latest
.
where
(
status:
status
)
running
=
from_builds
(
builds
,
:started_at
,
:finished_at
).
duration
running
=
from_builds
(
builds
,
:started_at
,
:finished_at
,
now
).
duration
total
=
from_builds
(
builds
,
:queued_at
,
:finished_at
).
duration
pending
=
pipeline
.
started_at
-
pipeline
.
created_at
pending
=
pipeline
.
started_at
-
pipeline
.
created_at
queuing
=
builds
.
inject
(
0
)
do
|
result
,
job
|
[
running
,
pending
+
total
-
running
]
result
+
((
job
.
started_at
||
now
)
-
(
job
.
queued_at
||
now
))
end
end
def
self
.
from_builds
(
builds
,
from
,
to
)
[
running
,
pending
+
queuing
]
now
=
Time
.
now
end
def
self
.
from_builds
(
builds
,
from
,
to
,
now
=
Time
.
now
)
periods
=
builds
.
map
do
|
b
|
periods
=
builds
.
map
do
|
b
|
Period
.
new
(
b
.
public_send
(
from
)
||
now
,
b
.
public_send
(
to
)
||
now
)
Period
.
new
(
b
.
public_send
(
from
)
||
now
,
b
.
public_send
(
to
)
||
now
)
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
7aaed299
...
@@ -156,7 +156,7 @@ describe Ci::Pipeline, models: true do
...
@@ -156,7 +156,7 @@ describe Ci::Pipeline, models: true do
pipeline
.
reload
pipeline
.
reload
expect
(
pipeline
.
duration
).
to
eq
(
40
)
expect
(
pipeline
.
duration
).
to
eq
(
40
)
expect
(
pipeline
.
pending_duration
).
to
eq
(
2
5
)
expect
(
pipeline
.
pending_duration
).
to
eq
(
4
5
)
end
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