diff options
author | James Lopez <james@jameslopez.es> | 2016-11-25 11:22:44 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-11-25 11:47:33 +0100 |
commit | 830f739b99b36f8862dadc524e4aa72ec5a3366e (patch) | |
tree | 744f10d8900493e2443b36d432cd6ed0f5e76f24 /app | |
parent | aa895a64d928f8292ff9df526831ae74d250f748 (diff) | |
download | gitlab-ce-830f739b99b36f8862dadc524e4aa72ec5a3366e.tar.gz |
use an empty total time when the build has not started yet so the UI knows
Diffstat (limited to 'app')
-rw-r--r-- | app/serializers/analytics_build_entity.rb | 6 | ||||
-rw-r--r-- | app/serializers/entity_date_helper.rb | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/app/serializers/analytics_build_entity.rb b/app/serializers/analytics_build_entity.rb index abefcd5cc02..206a7eadbcf 100644 --- a/app/serializers/analytics_build_entity.rb +++ b/app/serializers/analytics_build_entity.rb @@ -13,7 +13,7 @@ class AnalyticsBuildEntity < Grape::Entity end expose :duration, as: :total_time do |build| - distance_of_time_as_hash(build.duration.to_f) + build_started?(build) ? distance_of_time_as_hash(build.duration.to_f) : {} end expose :branch do @@ -37,4 +37,8 @@ class AnalyticsBuildEntity < Grape::Entity def url_to(route, build, id = nil) public_send("#{route}_url", build.project.namespace, build.project, id || build) end + + def build_started?(build) + build.duration && build[:started_at] + end end diff --git a/app/serializers/entity_date_helper.rb b/app/serializers/entity_date_helper.rb index 3cc98fb18a1..9607ad55a8b 100644 --- a/app/serializers/entity_date_helper.rb +++ b/app/serializers/entity_date_helper.rb @@ -2,7 +2,7 @@ module EntityDateHelper include ActionView::Helpers::DateHelper def interval_in_words(diff) - return 'not started' unless diff + return 'Not started' unless diff "#{distance_of_time_in_words(Time.now, diff)} ago" end |