diff options
author | Nermin Vehabovic <nermin.vehabovic90@gmail.com> | 2019-02-16 11:03:42 +0100 |
---|---|---|
committer | Nermin Vehabovic <nermin.vehabovic90@gmail.com> | 2019-02-16 11:03:42 +0100 |
commit | ff671366cb80a78c2846d5407d2380680a47a90d (patch) | |
tree | 8b13498b784daa5643520867e2333ba1954ec7ff /lib/api/helpers.rb | |
parent | 3967412f7e430d5a70560da8c7d6990a0aeec029 (diff) | |
download | gitlab-ce-ff671366cb80a78c2846d5407d2380680a47a90d.tar.gz |
Added: Include order by ID desc for tie breakers in pagination
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 2eb7b04711a..4d1b7714123 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -393,7 +393,15 @@ module API # rubocop: disable CodeReuse/ActiveRecord def reorder_projects(projects) - projects.reorder(params[:order_by] => params[:sort]) + projects.reorder(order_options_with_tie_breaker) + end + # rubocop: enable CodeReuse/ActiveRecord + + # rubocop: disable CodeReuse/ActiveRecord + def order_options_with_tie_breaker + {params[:order_by] => params[:sort]}.tap do |order| + order['id'] ||= 'desc' + end end # rubocop: enable CodeReuse/ActiveRecord |