Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e2710d72
Commit
e2710d72
authored
Jan 16, 2020
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move specific methods out of Base
https://gitlab.com/gitlab-org/gitlab/issues/37447
parent
8d416b7b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
26 deletions
+24
-26
lib/gitlab/pagination/base.rb
lib/gitlab/pagination/base.rb
+0
-25
lib/gitlab/pagination/keyset/pager.rb
lib/gitlab/pagination/keyset/pager.rb
+1
-1
lib/gitlab/pagination/offset_pagination.rb
lib/gitlab/pagination/offset_pagination.rb
+23
-0
No files found.
lib/gitlab/pagination/base.rb
View file @
e2710d72
...
...
@@ -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
lib/gitlab/pagination/keyset/pager.rb
View file @
e2710d72
...
...
@@ -3,7 +3,7 @@
module
Gitlab
module
Pagination
module
Keyset
class
Pager
class
Pager
<
Gitlab
::
Pagination
::
Base
attr_reader
:request
def
initialize
(
request
)
...
...
lib/gitlab/pagination/offset_pagination.rb
View file @
e2710d72
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment