Consider the case where we don't specify ref for pipeline
This commit is contained in:
parent
d38fb942e1
commit
3750b06b8c
1 changed files with 5 additions and 3 deletions
|
@ -91,11 +91,13 @@ module Ci
|
|||
scope :latest, ->(ref = nil) do
|
||||
max_id = unscope(:select)
|
||||
.select("max(#{quoted_table_name}.id)")
|
||||
.where(ref: ref)
|
||||
.group(:ref, :sha)
|
||||
|
||||
relation = ref ? where(ref: ref) : self
|
||||
relation.where(id: max_id)
|
||||
if ref
|
||||
where(ref: ref, id: max_id.where(ref: ref))
|
||||
else
|
||||
where(id: max_id)
|
||||
end
|
||||
end
|
||||
|
||||
def self.latest_status(ref = nil)
|
||||
|
|
Loading…
Reference in a new issue