diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-12-24 12:24:00 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-12-26 14:21:06 +0800 |
commit | 655289dd337588ad55f41a156cdc2ac318227979 (patch) | |
tree | 19637f964fb2ac27b4545837fa6103d999fd15fb | |
parent | 645412b57f558d58418aad278c9a3bf421439e1c (diff) | |
download | gitlab-ce-655289dd337588ad55f41a156cdc2ac318227979.tar.gz |
Order only for latest_successful_for
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8286#note_20461082
-rw-r--r-- | app/models/ci/pipeline.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index f2f6453b3b9..abbbddaa4f6 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -93,11 +93,8 @@ module Ci .select("max(#{quoted_table_name}.id)") .group(:ref, :sha) - if ref - where(id: max_id, ref: ref) - else - where(id: max_id) - end + relation = ref ? where(ref: ref) : self + relation.where(id: max_id) end def self.latest_status(ref = nil) @@ -105,7 +102,7 @@ module Ci end def self.latest_successful_for(ref) - success.latest(ref).first + success.latest(ref).order(id: :desc).first end def self.truncate_sha(sha) |