diff options
author | Marko, Peter <peter.marko@siemens.com> | 2018-06-15 12:16:21 +0200 |
---|---|---|
committer | Marko, Peter <peter.marko@siemens.com> | 2018-06-18 19:30:34 +0200 |
commit | 24865a4e17917fcf79d83508d18f683c5623ded8 (patch) | |
tree | 2ff7d9afda8af53d04afde358371b169a223e5d4 /lib/api | |
parent | 9d735dc27c09f0d9ce50711dbf99ddd8514f75b9 (diff) | |
download | gitlab-ce-24865a4e17917fcf79d83508d18f683c5623ded8.tar.gz |
Add id as second sort parameter for group sort by name
Adding primary key to database query order rule
generates deterministic sort result and thus pagination.
This is needed because subgroups can have identical names.
Signed-off-by: Marko, Peter <peter.marko@siemens.com>
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/groups.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 9d0b55c35c7..c7f41aba854 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -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 |