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
1593c81f
Commit
1593c81f
authored
Oct 13, 2020
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pagination without counts when appropriate
parent
517a05c7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
12 deletions
+13
-12
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+4
-5
app/helpers/pagination_helper.rb
app/helpers/pagination_helper.rb
+6
-4
app/views/projects/issues/_issues.html.haml
app/views/projects/issues/_issues.html.haml
+1
-1
app/views/projects/merge_requests/_merge_requests.html.haml
app/views/projects/merge_requests/_merge_requests.html.haml
+1
-1
ee/app/views/shared/_epics.html.haml
ee/app/views/shared/_epics.html.haml
+1
-1
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
1593c81f
...
@@ -41,10 +41,13 @@ module IssuableCollections
...
@@ -41,10 +41,13 @@ module IssuableCollections
end
end
def
set_pagination
def
set_pagination
row_count
=
finder
.
row_count
@issuables
=
@issuables
.
page
(
params
[
:page
])
@issuables
=
@issuables
.
page
(
params
[
:page
])
@issuables
=
per_page_for_relative_position
if
params
[
:sort
]
==
'relative_position'
@issuables
=
per_page_for_relative_position
if
params
[
:sort
]
==
'relative_position'
@issuables
=
@issuables
.
without_count
if
row_count
==
-
1
@issuable_meta_data
=
Gitlab
::
IssuableMetadata
.
new
(
current_user
,
@issuables
).
data
@issuable_meta_data
=
Gitlab
::
IssuableMetadata
.
new
(
current_user
,
@issuables
).
data
@total_pages
=
issuable_page_count
(
@issuables
)
@total_pages
=
page_count_for_relation
(
@issuables
,
row_count
)
end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
# rubocop:enable Gitlab/ModuleWithInstanceVariables
...
@@ -58,10 +61,6 @@ module IssuableCollections
...
@@ -58,10 +61,6 @@ module IssuableCollections
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
issuable_page_count
(
relation
)
page_count_for_relation
(
relation
,
finder
.
row_count
)
end
def
page_count_for_relation
(
relation
,
row_count
)
def
page_count_for_relation
(
relation
,
row_count
)
limit
=
relation
.
limit_value
.
to_f
limit
=
relation
.
limit_value
.
to_f
...
...
app/helpers/pagination_helper.rb
View file @
1593c81f
# frozen_string_literal: true
# frozen_string_literal: true
module
PaginationHelper
module
PaginationHelper
def
paginate_collection
(
collection
,
remote:
nil
)
# total_pages will be inferred from the collection if nil. It is ignored if
# the collection is a Kaminari::PaginatableWithoutCount
def
paginate_collection
(
collection
,
remote:
nil
,
total_pages:
nil
)
if
collection
.
is_a?
(
Kaminari
::
PaginatableWithoutCount
)
if
collection
.
is_a?
(
Kaminari
::
PaginatableWithoutCount
)
paginate_without_count
(
collection
)
paginate_without_count
(
collection
)
elsif
collection
.
respond_to?
(
:total_pages
)
elsif
collection
.
respond_to?
(
:total_pages
)
paginate_with_count
(
collection
,
remote:
remote
)
paginate_with_count
(
collection
,
remote:
remote
,
total_pages:
total_pages
)
end
end
end
end
...
@@ -17,7 +19,7 @@ module PaginationHelper
...
@@ -17,7 +19,7 @@ module PaginationHelper
)
)
end
end
def
paginate_with_count
(
collection
,
remote:
nil
)
def
paginate_with_count
(
collection
,
remote:
nil
,
total_pages:
nil
)
paginate
(
collection
,
remote:
remote
,
theme:
'gitlab'
)
paginate
(
collection
,
remote:
remote
,
theme:
'gitlab'
,
total_pages:
total_pages
)
end
end
end
end
app/views/projects/issues/_issues.html.haml
View file @
1593c81f
...
@@ -20,4 +20,4 @@
...
@@ -20,4 +20,4 @@
=
render
empty_state_path
=
render
empty_state_path
-
if
@issues
.
present?
-
if
@issues
.
present?
=
paginate
@issues
,
theme:
"gitlab"
,
total_pages:
@total_pages
=
paginate
_collection
@issues
,
total_pages:
@total_pages
app/views/projects/merge_requests/_merge_requests.html.haml
View file @
1593c81f
...
@@ -5,4 +5,4 @@
...
@@ -5,4 +5,4 @@
=
render
'shared/empty_states/merge_requests'
=
render
'shared/empty_states/merge_requests'
-
if
@merge_requests
.
present?
-
if
@merge_requests
.
present?
=
paginate
@merge_requests
,
theme:
"gitlab"
,
total_pages:
@total_pages
=
paginate
_collection
@merge_requests
,
total_pages:
@total_pages
ee/app/views/shared/_epics.html.haml
View file @
1593c81f
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
%ul
.content-list.issuable-list
%ul
.content-list.issuable-list
=
render
partial:
'groups/epics/epic'
,
collection:
@epics
=
render
partial:
'groups/epics/epic'
,
collection:
@epics
=
paginate
@epics
,
theme:
"gitlab"
=
paginate
_collection
@epics
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