Skip to content
Snippets Groups Projects
Commit 0e8266f2 authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Revert "Use JSON type for sorting parameter (halfway)"

This reverts commit 34127cb13ad72f65a24bdc8fc051363d3edd77cb.
parent 22a4d124
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -108,20 +108,16 @@ class PipelinesFinder
end
 
def sort_items(items)
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
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)
end
end
Loading
Loading
@@ -22,10 +22,10 @@ module API
optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines'
optional :name, type: String, desc: 'The name of user who triggered pipelines'
optional :username, type: String, desc: 'The username of user who triggered pipelines'
optional :sort, type: JSON, desc: 'order_by and asc_desc' do
requires :order_by, type: String, values: %w[id status ref user_id]
requires :asc_desc, type: String, values: %w[asc desc]
end
optional :order_by, type: String, values: %w[id status ref user_id], default: 'id',
desc: 'The order_by which is combined with a sort'
optional :sort, type: String, values: %w[asc desc], default: 'desc',
desc: 'The sort method which is combined with an order_by'
end
get ':id/pipelines' do
authorize! :read_pipeline, user_project
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment