Commit 7351c269 authored by Lin Jen-Shin's avatar Lin Jen-Shin
parent 3a68c989
......@@ -88,7 +88,8 @@ module Gitlab
def from_pipeline(pipeline)
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)
end
......@@ -101,8 +102,9 @@ module Gitlab
from_periods(periods)
end
# periods should be sorted by `first`
def from_periods(periods)
process_duration(process_periods(periods.sort_by(&:first)))
process_duration(process_periods(periods))
end
private
......
......@@ -110,6 +110,6 @@ describe Gitlab::Ci::PipelineDuration do
Gitlab::Ci::PipelineDuration::Period.new(first, last)
end
Gitlab::Ci::PipelineDuration.from_periods(periods)
Gitlab::Ci::PipelineDuration.from_periods(periods.sort_by(&:first))
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