From 13d009ce545271c6d0422a8df61c74028439d8bd Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 23 Dec 2016 18:17:25 +0800 Subject: Prefer oneline and Rubocop prefers ternary operator Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8286/diffs#note_20433402 --- app/models/ci/pipeline.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 5494a8da0d9..6894a5763ff 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -93,13 +93,8 @@ module Ci .select("max(#{quoted_table_name}.id)") .group(:ref, :sha) - query = if ref - where(id: max_id, ref: ref) - else - where(id: max_id) - end - - query.order(id: :desc) + relation = ref ? where(ref: ref) : self + relation.where(id: max_id).order(id: :desc) end def self.latest_status(ref = nil) -- cgit v1.2.1