summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorsujay patel <sujaypatel1996@gmail.com>2019-06-13 01:33:21 +0530
committersujay <sujay.patel@caavo.com>2019-07-05 14:24:56 +0530
commite241c89977c32fabbbe5a49c1ba69564d5e09e31 (patch)
treee95ac3a41d7937b0451cda82930668f1d7eaf3fa /app/finders
parentb71250ca0f1b9df4f728bdb322502e3544058ca5 (diff)
downloadgitlab-ce-e241c89977c32fabbbe5a49c1ba69564d5e09e31.tar.gz
Adding order by to list runner jobs api.
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/runner_jobs_finder.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/app/finders/runner_jobs_finder.rb b/app/finders/runner_jobs_finder.rb
index f1ee1d38255..ef90817416a 100644
--- a/app/finders/runner_jobs_finder.rb
+++ b/app/finders/runner_jobs_finder.rb
@@ -3,7 +3,7 @@
class RunnerJobsFinder
attr_reader :runner, :params
- ALLOWED_INDEXED_COLUMNS = %w[id created_at].freeze
+ ALLOWED_INDEXED_COLUMNS = %w[id].freeze
def initialize(runner, params = {})
@runner = runner
@@ -28,13 +28,10 @@ class RunnerJobsFinder
# rubocop: disable CodeReuse/ActiveRecord
def sort_items(items)
- order_by = if ALLOWED_INDEXED_COLUMNS.include?(params[:order_by])
- params[:order_by]
- else
- :id
- end
+ return items unless ALLOWED_INDEXED_COLUMNS.include?(params[:order_by])
- sort = if params[:sort] =~ /\A(ASC|DESC)\z/i
+ order_by = params[:order_by]
+ sort = if /\A(ASC|DESC)\z/i.match?(params[:sort])
params[:sort]
else
:desc