diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-01-11 19:45:35 +0300 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-01-17 10:47:55 +0300 |
commit | 310d209b67938acdb1cde3cf5622440bf42c5bc4 (patch) | |
tree | 0b2881440a8f02a2f2e964946984ec3ab7f5fea2 /lib | |
parent | 3228ac06a019c9126b965ff32e354d10011a4f76 (diff) |
Adds sorting to deployments API
Adds sorting to deployments API through the `order_by` and sort
`fields`.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/deployments.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/api/deployments.rb b/lib/api/deployments.rb index 1efee9a1324..184fae0eb76 100644 --- a/lib/api/deployments.rb +++ b/lib/api/deployments.rb @@ -15,11 +15,13 @@ module API end params do use :pagination + optional :order_by, type: String, values: %w[id iid created_at ref], default: 'id', desc: 'Return deployments ordered by `id` or `iid` or `created_at` or `ref`' + optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)' end get ':id/deployments' do authorize! :read_deployment, user_project - present paginate(user_project.deployments), with: Entities::Deployment + present paginate(user_project.deployments.order(params[:order_by] => params[:sort])), with: Entities::Deployment end desc 'Gets a specific deployment' do |