diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-07 12:11:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-07 12:11:43 +0300 |
commit | 378308b6cde44eb1a320b9202ff8946a911f35f6 (patch) | |
tree | 3031a645455dbbcdb2961dd09c15100fa28ed8e1 /lib/gitlab/pagination/keyset/cursor_based_request_context.rb | |
parent | 777dc3053f8433a9f5c9cc868325e16eac5d93e5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/pagination/keyset/cursor_based_request_context.rb')
-rw-r--r-- | lib/gitlab/pagination/keyset/cursor_based_request_context.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/gitlab/pagination/keyset/cursor_based_request_context.rb b/lib/gitlab/pagination/keyset/cursor_based_request_context.rb index d9c118ceef5..18390f5b59d 100644 --- a/lib/gitlab/pagination/keyset/cursor_based_request_context.rb +++ b/lib/gitlab/pagination/keyset/cursor_based_request_context.rb @@ -4,11 +4,12 @@ module Gitlab module Pagination module Keyset class CursorBasedRequestContext - attr_reader :request - delegate :params, :header, to: :request + DEFAULT_SORT_DIRECTION = :desc + attr_reader :request_context + delegate :params, to: :request_context - def initialize(request) - @request = request + def initialize(request_context) + @request_context = request_context end def per_page @@ -21,9 +22,13 @@ module Gitlab def apply_headers(cursor_for_next_page) Gitlab::Pagination::Keyset::HeaderBuilder - .new(self) + .new(request_context) .add_next_page_header({ cursor: cursor_for_next_page }) end + + def order_by + { params[:order_by].to_sym => params[:sort]&.to_sym || DEFAULT_SORT_DIRECTION } + end end end end |