Show wall-clock time when showing pipeline instead of:

cumulative builds time. Closes #17007
This commit is contained in:
Lin Jen-Shin 2016-08-09 18:42:42 +08:00
parent 551ffc0a4d
commit 5643cd6b49
4 changed files with 13 additions and 4 deletions

View file

@ -17,6 +17,11 @@ module TimeHelper
def duration_in_numbers(finished_at, started_at)
interval = interval_in_seconds(started_at, finished_at)
duration_in_numbers_from_interval(interval)
end
def duration_in_numbers_from_interval(interval)
time_format = interval < 1.hour ? "%M:%S" : "%H:%M:%S"
Time.at(interval).utc.strftime(time_format)

View file

@ -213,6 +213,10 @@ module Ci
]
end
def wall_clock_duration
finished_at.to_i - started_at.to_i if finished_at && started_at
end
private
def build_builds_for_stages(stages, user, status, trigger_request)

View file

@ -46,10 +46,10 @@
\-
%td
- if pipeline.started_at && pipeline.finished_at
- if pipeline.wall_clock_duration
%p.duration
= custom_icon("icon_timer")
= duration_in_numbers(pipeline.finished_at, pipeline.started_at)
= duration_in_numbers_from_interval(pipeline.wall_clock_duration)
- if pipeline.finished_at
%p.finished-at
= icon("calendar")

View file

@ -7,9 +7,9 @@
- if @pipeline.ref
for
= link_to @pipeline.ref, namespace_project_commits_path(@project.namespace, @project, @pipeline.ref), class: "monospace"
- if @pipeline.duration
- if @pipeline.wall_clock_duration
in
= time_interval_in_words @pipeline.duration
= time_interval_in_words(@pipeline.wall_clock_duration)
.pull-right
= link_to namespace_project_pipeline_path(@project.namespace, @project, @pipeline), class: "ci-status ci-#{@pipeline.status}" do