Lin Jen-Shin 2016-09-06 19:36:07 +08:00
parent 3a68c98973
commit 7351c269de
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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