diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-06-19 10:46:24 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-06-19 10:46:24 +0000 |
commit | 57a2ac1869de943f86aa3465caa37e8f1ced0099 (patch) | |
tree | 3baf4a90299e7bb01e58841cb500767863a52cd7 /lib/api/groups.rb | |
parent | 74cecce55a166bb56064c6d45a7ddc11f57af991 (diff) | |
parent | 24865a4e17917fcf79d83508d18f683c5623ded8 (diff) | |
download | gitlab-ce-57a2ac1869de943f86aa3465caa37e8f1ced0099.tar.gz |
Merge branch 'more-group-api-sorting-options' into 'master'
Fix group pagination and add sort by id to groups and subgroups
Closes #47409
See merge request gitlab-org/gitlab-ce!19665
Diffstat (limited to 'lib/api/groups.rb')
-rw-r--r-- | lib/api/groups.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 03b6b30a0d8..c7f41aba854 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -32,7 +32,7 @@ module API optional :all_available, type: Boolean, desc: 'Show all group that you have access to' optional :search, type: String, desc: 'Search for a specific group' optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user' - optional :order_by, type: String, values: %w[name path], default: 'name', desc: 'Order by name or path' + optional :order_by, type: String, values: %w[name path id], default: 'name', desc: 'Order by name, path or id' optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)' use :pagination end @@ -46,7 +46,9 @@ module API groups = GroupsFinder.new(current_user, find_params).execute groups = groups.search(params[:search]) if params[:search].present? groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present? - groups = groups.reorder(params[:order_by] => params[:sort]) + order_options = { params[:order_by] => params[:sort] } + order_options["id"] ||= "asc" + groups = groups.reorder(order_options) groups end |