Revert "Use JSON type for sorting parameter (halfway)"
This reverts commit 34127cb13ad72f65a24bdc8fc051363d3edd77cb.
This commit is contained in:
parent
22a4d124f7
commit
0e8266f238
2 changed files with 15 additions and 19 deletions
|
@ -108,20 +108,16 @@ class PipelinesFinder
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_items(items)
|
def sort_items(items)
|
||||||
return items.order(id: :desc) unless params[:sort].present?
|
order_by = if %w[id status ref user_id].include?(params[:order_by]) # Allow only indexed columns
|
||||||
params[:sort].each do |s|
|
params[:order_by]
|
||||||
order_by = if %w[id status ref user_id].include?(s['order_by']) # Allow only indexed columns
|
else
|
||||||
s['order_by']
|
:id
|
||||||
else
|
end
|
||||||
:id
|
sort = if params[:sort] =~ /\A(ASC|DESC)\z/i
|
||||||
end
|
params[:sort]
|
||||||
sort = if s['asc_desc'] =~ /\A(ASC|DESC)\z/i
|
else
|
||||||
s['asc_desc']
|
:desc
|
||||||
else
|
end
|
||||||
:desc
|
items.order(order_by => sort)
|
||||||
end
|
|
||||||
items = items.order(order_by => sort)
|
|
||||||
end
|
|
||||||
items
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,10 +22,10 @@ module API
|
||||||
optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines'
|
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 :name, type: String, desc: 'The name of user who triggered pipelines'
|
||||||
optional :username, type: String, desc: 'The username 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
|
optional :order_by, type: String, values: %w[id status ref user_id], default: 'id',
|
||||||
requires :order_by, type: String, values: %w[id status ref user_id]
|
desc: 'The order_by which is combined with a sort'
|
||||||
requires :asc_desc, type: String, values: %w[asc desc]
|
optional :sort, type: String, values: %w[asc desc], default: 'desc',
|
||||||
end
|
desc: 'The sort method which is combined with an order_by'
|
||||||
end
|
end
|
||||||
get ':id/pipelines' do
|
get ':id/pipelines' do
|
||||||
authorize! :read_pipeline, user_project
|
authorize! :read_pipeline, user_project
|
||||||
|
|
Loading…
Reference in a new issue