Don't call anything on a block, use simple if
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7333#note_20058743
This commit is contained in:
parent
cc6f578d5f
commit
b4a7e7cfbf
|
@ -89,13 +89,15 @@ module Ci
|
|||
|
||||
# ref can't be HEAD or SHA, can only be branch/tag name
|
||||
scope :latest, ->(ref = nil) do
|
||||
max_id = unscope(:select).select("max(#{quoted_table_name}.id)")
|
||||
max_id = unscope(:select)
|
||||
.select("max(#{quoted_table_name}.id)")
|
||||
.group(:ref, :sha)
|
||||
|
||||
if ref
|
||||
where(ref: ref)
|
||||
where(id: max_id, ref: ref)
|
||||
else
|
||||
self
|
||||
end.where(id: max_id.group(:ref, :sha))
|
||||
where(id: max_id)
|
||||
end
|
||||
end
|
||||
|
||||
def self.latest_status(ref = nil)
|
||||
|
|
Loading…
Reference in New Issue