Skip to content
Snippets Groups Projects
Commit 3750b06b authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

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

parent d38fb942
No related branches found
No related tags found
No related merge requests found
Loading
@@ -91,11 +91,13 @@ module Ci
Loading
@@ -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)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment