summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-03-22 02:37:19 +0900
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-03 02:11:51 +0900
commit22a4d124f70598c7c21b08b11db3f38c7bcb71ec (patch)
treee9abd29cc89995c66b499ce8200d6bcf69de969e /app/finders
parent98ac988d4d9525b3f07a19e495a9c2666ebee3c6 (diff)
downloadgitlab-ce-22a4d124f70598c7c21b08b11db3f38c7bcb71ec.tar.gz
Use JSON type for sorting parameter (halfway)
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/pipelines_finder.rb26
1 files changed, 15 insertions, 11 deletions
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb
index 22507472e15..d56cf8fe790 100644
--- a/app/finders/pipelines_finder.rb
+++ b/app/finders/pipelines_finder.rb
@@ -108,16 +108,20 @@ class PipelinesFinder
end
def sort_items(items)
- order_by = if %w[id status ref user_id].include?(params[:order_by]) # Allow only indexed columns
- params[:order_by]
- else
- :id
- end
- sort = if params[:sort] =~ /\A(ASC|DESC)\z/i
- params[:sort]
- else
- :desc
- end
- items.order(order_by => sort)
+ return items.order(id: :desc) unless params[:sort].present?
+ params[:sort].each do |s|
+ order_by = if %w[id status ref user_id].include?(s['order_by']) # Allow only indexed columns
+ s['order_by']
+ else
+ :id
+ end
+ sort = if s['asc_desc'] =~ /\A(ASC|DESC)\z/i
+ s['asc_desc']
+ else
+ :desc
+ end
+ items = items.order(order_by => sort)
+ end
+ items
end
end