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
4e7230a9
Commit
4e7230a9
authored
Nov 29, 2019
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use symbol keys consistently
parent
cab79f74
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
lib/gitlab/pagination/keyset/page.rb
lib/gitlab/pagination/keyset/page.rb
+3
-3
lib/gitlab/pagination/keyset/pager.rb
lib/gitlab/pagination/keyset/pager.rb
+2
-2
spec/lib/gitlab/pagination/keyset/page_spec.rb
spec/lib/gitlab/pagination/keyset/page_spec.rb
+3
-3
spec/lib/gitlab/pagination/keyset/request_context_spec.rb
spec/lib/gitlab/pagination/keyset/request_context_spec.rb
+3
-3
No files found.
lib/gitlab/pagination/keyset/page.rb
View file @
4e7230a9
...
...
@@ -12,8 +12,8 @@ module Gitlab
attr_reader
:order_by
def
initialize
(
order_by:
{},
lower_bounds:
nil
,
per_page:
DEFAULT_PAGE_SIZE
,
end_reached:
false
)
@order_by
=
order_by
.
with_indifferent_acces
s
@lower_bounds
=
lower_bounds
@order_by
=
order_by
.
symbolize_key
s
@lower_bounds
=
lower_bounds
&
.
symbolize_keys
@per_page
=
per_page
@end_reached
=
end_reached
end
...
...
@@ -34,7 +34,7 @@ module Gitlab
# Uses identical order_by/per_page information for the next page
def
next
(
lower_bounds
,
end_reached
)
dup
.
tap
do
|
next_page
|
next_page
.
lower_bounds
=
lower_bounds
next_page
.
lower_bounds
=
lower_bounds
&
.
symbolize_keys
next_page
.
end_reached
=
end_reached
end
end
...
...
lib/gitlab/pagination/keyset/pager.rb
View file @
4e7230a9
...
...
@@ -44,9 +44,9 @@ module Gitlab
end
def
validate_order!
(
rel
)
present_order
=
rel
.
order_values
.
map
{
|
val
|
[
val
.
expr
.
name
,
val
.
direction
]
}.
last
(
2
).
to_h
present_order
=
rel
.
order_values
.
map
{
|
val
|
[
val
.
expr
.
name
.
to_sym
,
val
.
direction
]
}.
last
(
2
).
to_h
unless
page
.
order_by
.
with_indifferent_access
==
present_order
.
with_indifferent_access
unless
page
.
order_by
==
present_order
raise
ArgumentError
,
"Page's order_by does not match the relation's order:
#{
present_order
}
vs
#{
page
.
order_by
}
"
end
end
...
...
spec/lib/gitlab/pagination/keyset/page_spec.rb
View file @
4e7230a9
...
...
@@ -33,12 +33,12 @@ describe Gitlab::Pagination::Keyset::Page do
let
(
:page
)
{
described_class
.
new
(
order_by:
order_by
,
lower_bounds:
lower_bounds
,
per_page:
per_page
,
end_reached:
end_reached
)
}
subject
{
page
.
next
(
new_lower_bounds
,
new_end_reached
)
}
let
(
:order_by
)
{
{}
}
let
(
:lower_bounds
)
{
double
}
let
(
:order_by
)
{
{
id: :desc
}
}
let
(
:lower_bounds
)
{
{
id:
42
}
}
let
(
:per_page
)
{
10
}
let
(
:end_reached
)
{
false
}
let
(
:new_lower_bounds
)
{
double
}
let
(
:new_lower_bounds
)
{
{
id:
21
}
}
let
(
:new_end_reached
)
{
true
}
it
'copies over order_by'
do
...
...
spec/lib/gitlab/pagination/keyset/request_context_spec.rb
View file @
4e7230a9
...
...
@@ -14,7 +14,7 @@ describe Gitlab::Pagination::Keyset::RequestContext do
it
'extracts order_by/sorting information'
do
page
=
subject
expect
(
page
.
order_by
).
to
eq
(
'id'
=>
:desc
)
expect
(
page
.
order_by
).
to
eq
(
id:
:desc
)
end
end
...
...
@@ -24,7 +24,7 @@ describe Gitlab::Pagination::Keyset::RequestContext do
it
'extracts order_by/sorting information and adds tie breaker'
do
page
=
subject
expect
(
page
.
order_by
).
to
eq
(
'created_at'
=>
:desc
,
'id'
=>
:desc
)
expect
(
page
.
order_by
).
to
eq
(
created_at: :desc
,
id:
:desc
)
end
end
...
...
@@ -34,7 +34,7 @@ describe Gitlab::Pagination::Keyset::RequestContext do
it
'defaults to tie breaker'
do
page
=
subject
expect
(
page
.
order_by
).
to
eq
({
'id'
=>
:desc
})
expect
(
page
.
order_by
).
to
eq
({
id:
:desc
})
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