Order only for latest_successful_for

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8286#note_20461082
This commit is contained in:
Lin Jen-Shin 2016-12-24 12:24:00 +08:00
parent 645412b57f
commit 655289dd33

View file

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