Commit 7351c269 authored by Lin Jen-Shin's avatar Lin Jen-Shin
parent 3a68c989
...@@ -88,7 +88,8 @@ module Gitlab ...@@ -88,7 +88,8 @@ module Gitlab
def from_pipeline(pipeline) def from_pipeline(pipeline)
status = %w[success failed running canceled] status = %w[success failed running canceled]
builds = pipeline.builds.latest.where(status: status) builds = pipeline.builds.latest.
where(status: status).where.not(started_at: nil).order(:started_at)
from_builds(builds, :started_at, :finished_at) from_builds(builds, :started_at, :finished_at)
end end
...@@ -101,8 +102,9 @@ module Gitlab ...@@ -101,8 +102,9 @@ module Gitlab
from_periods(periods) from_periods(periods)
end end
# periods should be sorted by `first`
def from_periods(periods) def from_periods(periods)
process_duration(process_periods(periods.sort_by(&:first))) process_duration(process_periods(periods))
end end
private private
......
...@@ -110,6 +110,6 @@ describe Gitlab::Ci::PipelineDuration do ...@@ -110,6 +110,6 @@ describe Gitlab::Ci::PipelineDuration do
Gitlab::Ci::PipelineDuration::Period.new(first, last) Gitlab::Ci::PipelineDuration::Period.new(first, last)
end end
Gitlab::Ci::PipelineDuration.from_periods(periods) Gitlab::Ci::PipelineDuration.from_periods(periods.sort_by(&:first))
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment