Commit b4a7e7cf authored by Lin Jen-Shin's avatar Lin Jen-Shin

Don't call anything on a block, use simple if

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7333#note_20058743
parent cc6f578d
......@@ -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)
......
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