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

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

parent d38fb942
No related branches found
No related tags found
Loading
......@@ -91,11 +91,13 @@ class Pipeline < ActiveRecord::Base
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)
......
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