Sort by database, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6084#note_14991226 and https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6084#note_14994233
This commit is contained in:
parent
3a68c98973
commit
7351c269de
2 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue