summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-08-29 20:24:48 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-08-29 20:24:48 +0800
commitace0a005b8bda05db224c21ac5ea691c3ffb6fb6 (patch)
tree9df3a073e7485ef9cd4a0347af932e4a241dc2cb /app
parent64366209ffe23aff467f707e85a10f8a5b4a39cd (diff)
downloadgitlab-ce-ace0a005b8bda05db224c21ac5ea691c3ffb6fb6.tar.gz
Smartly calculate real running time and pending time
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 03812cd195f..e59c90e7e0c 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -258,7 +258,13 @@ module Ci
end
def update_duration
- self.duration = calculate_duration
+ calculated_status = %w[success failed running canceled]
+ calculated_builds = builds.latest.where(status: calculated_status)
+ calculator = PipelineDuration.from_builds(calculated_builds)
+
+ self.duration = calculator.duration
+ self.pending_duration =
+ started_at - created_at + calculator.pending_duration
end
def execute_hooks