summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-23 18:17:25 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-12-23 18:17:25 +0800
commit13d009ce545271c6d0422a8df61c74028439d8bd (patch)
treec076d7d80fd66cc9b18e58f081ac81657c5a971c
parentb63f2794f076a7394c8a000829a632bcffef2b00 (diff)
downloadgitlab-ce-13d009ce545271c6d0422a8df61c74028439d8bd.tar.gz
Prefer oneline and Rubocop prefers ternary operator
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8286/diffs#note_20433402
-rw-r--r--app/models/ci/pipeline.rb9
1 files 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)