diff options
author | Rémy Coutable <remy@rymai.me> | 2018-01-17 13:01:03 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-17 13:01:03 +0300 |
commit | ad5ce890488edb136bb193eff0ffb9513d4a6798 (patch) | |
tree | 3590025f4bd63afecab06d8a7acd80c0e155b3c0 /lib | |
parent | a3b0adb4c856ebd9e8761471c5372f0a10fe8829 (diff) | |
parent | 310d209b67938acdb1cde3cf5622440bf42c5bc4 (diff) |
Merge branch '41118-add-sorting-to-deployments-api' into 'master'
Resolve "Enable ordering and sorting for the Deployments API"
Closes #41118
See merge request gitlab-org/gitlab-ce!16396
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 |