diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 03:09:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 03:09:18 +0300 |
commit | a1565a8243dd2cce29d0489d5ed40f9291d828d4 (patch) | |
tree | ed32d41117be241062ce5fd6a9576ed8a99fcffc /lib/gitlab/pagination | |
parent | 40254b9ace2a74a3c9f1cc51a1b1d5e3e78c1ae9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/pagination')
-rw-r--r-- | lib/gitlab/pagination/base.rb | 25 | ||||
-rw-r--r-- | lib/gitlab/pagination/keyset/pager.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/pagination/offset_pagination.rb | 23 |
3 files changed, 24 insertions, 26 deletions
diff --git a/lib/gitlab/pagination/base.rb b/lib/gitlab/pagination/base.rb index 6402b9c0f76..a8a3397eba2 100644 --- a/lib/gitlab/pagination/base.rb +++ b/lib/gitlab/pagination/base.rb @@ -10,31 +10,6 @@ module Gitlab def finalize(records) # Optional: Called with the actual set of records end - - private - - def per_page - @per_page ||= params[:per_page] - end - - def base_request_uri - @base_request_uri ||= URI.parse(request.url).tap do |uri| - uri.host = Gitlab.config.gitlab.host - uri.port = Gitlab.config.gitlab.port - end - end - - def build_page_url(query_params:) - base_request_uri.tap do |uri| - uri.query = query_params - end.to_s - end - - def page_href(next_page_params = {}) - query_params = params.merge(**next_page_params, per_page: per_page).to_query - - build_page_url(query_params: query_params) - end end end end diff --git a/lib/gitlab/pagination/keyset/pager.rb b/lib/gitlab/pagination/keyset/pager.rb index 6eaa7f3ba87..6a2ae20f3b8 100644 --- a/lib/gitlab/pagination/keyset/pager.rb +++ b/lib/gitlab/pagination/keyset/pager.rb @@ -3,7 +3,7 @@ module Gitlab module Pagination module Keyset - class Pager + class Pager < Gitlab::Pagination::Base attr_reader :request def initialize(request) diff --git a/lib/gitlab/pagination/offset_pagination.rb b/lib/gitlab/pagination/offset_pagination.rb index bf31f252a6b..11a5ef4e518 100644 --- a/lib/gitlab/pagination/offset_pagination.rb +++ b/lib/gitlab/pagination/offset_pagination.rb @@ -72,6 +72,29 @@ module Gitlab def data_without_counts?(paginated_data) paginated_data.is_a?(Kaminari::PaginatableWithoutCount) end + + def base_request_uri + @base_request_uri ||= URI.parse(request.url).tap do |uri| + uri.host = Gitlab.config.gitlab.host + uri.port = Gitlab.config.gitlab.port + end + end + + def build_page_url(query_params:) + base_request_uri.tap do |uri| + uri.query = query_params + end.to_s + end + + def page_href(next_page_params = {}) + query_params = params.merge(**next_page_params, per_page: per_page).to_query + + build_page_url(query_params: query_params) + end + + def per_page + @per_page ||= params[:per_page] + end end end end |