Commit 3750b06b authored by Lin Jen-Shin's avatar Lin Jen-Shin

Consider the case where we don't specify ref for pipeline

parent d38fb942
...@@ -91,11 +91,13 @@ module Ci ...@@ -91,11 +91,13 @@ module Ci
scope :latest, ->(ref = nil) do scope :latest, ->(ref = nil) do
max_id = unscope(:select) max_id = unscope(:select)
.select("max(#{quoted_table_name}.id)") .select("max(#{quoted_table_name}.id)")
.where(ref: ref)
.group(:ref, :sha) .group(:ref, :sha)
relation = ref ? where(ref: ref) : self if ref
relation.where(id: max_id) where(ref: ref, id: max_id.where(ref: ref))
else
where(id: max_id)
end
end end
def self.latest_status(ref = nil) def self.latest_status(ref = nil)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment