summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-07-07 22:17:55 +0000
committerRobert Speicher <robert@gitlab.com>2016-07-07 22:17:55 +0000
commit39fbec941939f76ec08a25f537cc3f4a308e21f5 (patch)
treea68be2fcc445d9c4efd10abf6000c6a29efdafd0
parent5541e55c491eb86567c8c1f28457e894a4155dd1 (diff)
parent4498bb78332ba5f03b23a4f8ddba2eb034830b39 (diff)
downloadgitlab-ce-39fbec941939f76ec08a25f537cc3f4a308e21f5.tar.gz
Merge branch '18181-pipeline-duration' into 'master'
Update time format of pipeline duration Closes #18181 Part of #18920 See merge request !5121
-rw-r--r--app/helpers/time_helper.rb7
-rw-r--r--app/views/projects/ci/pipelines/_pipeline.html.haml2
2 files changed, 8 insertions, 1 deletions
diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb
index b04b0a5114c..8cb82c2d5cc 100644
--- a/app/helpers/time_helper.rb
+++ b/app/helpers/time_helper.rb
@@ -23,4 +23,11 @@ module TimeHelper
def date_from_to(from, to)
"#{from.to_s(:short)} - #{to.to_s(:short)}"
end
+
+ def duration_in_numbers(finished_at, started_at)
+ diff_in_seconds = finished_at.to_i - started_at.to_i
+ time_format = diff_in_seconds < 1.hour ? "%M:%S" : "%H:%M:%S"
+
+ Time.at(diff_in_seconds).utc.strftime(time_format)
+ end
end
diff --git a/app/views/projects/ci/pipelines/_pipeline.html.haml b/app/views/projects/ci/pipelines/_pipeline.html.haml
index e38d1ff5ff0..af8dd5cd02c 100644
--- a/app/views/projects/ci/pipelines/_pipeline.html.haml
+++ b/app/views/projects/ci/pipelines/_pipeline.html.haml
@@ -45,7 +45,7 @@
%td
- if pipeline.started_at && pipeline.finished_at
%p.duration
- #{duration_in_words(pipeline.finished_at, pipeline.started_at)}
+ = duration_in_numbers(pipeline.finished_at, pipeline.started_at)
%td
.controls.hidden-xs.pull-right