summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline_duration.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/pipeline_duration.rb')
-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)