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
1 merge request!9306Optimize Ci::Pipeline.latest query
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment