summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-08 21:47:19 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-09-08 21:49:17 +0800
commit27a3f1182ae2664f27150bd91f74a4f732cfd4af (patch)
treef0f135935db73383f0cb5adf3fd477c08605cd68
parent7b75476610cd4ac9f1c8b83b721e6bc524b781a1 (diff)
downloadgitlab-ce-27a3f1182ae2664f27150bd91f74a4f732cfd4af.tar.gz
Split try_merge_period into overlap? and merge:
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6084#note_15083507
-rw-r--r--lib/gitlab/ci/pipeline_duration.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/gitlab/ci/pipeline_duration.rb b/lib/gitlab/ci/pipeline_duration.rb
index 10ad70f14fa..311f5a7f8d8 100644
--- a/lib/gitlab/ci/pipeline_duration.rb
+++ b/lib/gitlab/ci/pipeline_duration.rb
@@ -115,10 +115,10 @@ module Gitlab
return periods if periods.empty?
periods.drop(1).inject([periods.first]) do |result, current|
- merged = try_merge_period(result.last, current)
+ previous = result.last
- if merged
- result[-1] = merged
+ if overlap?(previous, current)
+ result[-1] = merge(previous, current)
result
else
result << current
@@ -126,10 +126,12 @@ module Gitlab
end
end
- def try_merge_period(previous, current)
- if current.first <= previous.last
- Period.new(previous.first, [previous.last, current.last].max)
- end
+ def overlap?(previous, current)
+ current.first <= previous.last
+ end
+
+ def merge(previous, current)
+ Period.new(previous.first, [previous.last, current.last].max)
end
def process_duration(periods)