summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-08-09 18:42:42 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-08-09 18:42:42 +0800
commit5643cd6b497c2850fb585cf263d3019953c282f5 (patch)
tree1137ab93e279fa2ef31525b41b8a19ff60c55350 /app
parent551ffc0a4d25a381e9f8f6a8d6f2793bb87f3145 (diff)
downloadgitlab-ce-5643cd6b497c2850fb585cf263d3019953c282f5.tar.gz
Show wall-clock time when showing pipeline instead of:
cumulative builds time. Closes #17007
Diffstat (limited to 'app')
-rw-r--r--app/helpers/time_helper.rb5
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/views/projects/ci/pipelines/_pipeline.html.haml4
-rw-r--r--app/views/projects/pipelines/_info.html.haml4
4 files changed, 13 insertions, 4 deletions
diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb
index 790001222f1..a031abb8676 100644
--- a/app/helpers/time_helper.rb
+++ b/app/helpers/time_helper.rb
@@ -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)
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index bce6a992af6..db29df668bf 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -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)
diff --git a/app/views/projects/ci/pipelines/_pipeline.html.haml b/app/views/projects/ci/pipelines/_pipeline.html.haml
index 9a594877803..60c3c27bd1a 100644
--- a/app/views/projects/ci/pipelines/_pipeline.html.haml
+++ b/app/views/projects/ci/pipelines/_pipeline.html.haml
@@ -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")
diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml
index 8289aefcde7..a0f6c19350d 100644
--- a/app/views/projects/pipelines/_info.html.haml
+++ b/app/views/projects/pipelines/_info.html.haml
@@ -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