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
5a4ac5f6
Commit
5a4ac5f6
authored
Oct 02, 2020
by
Alan Paruszewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix problem with sorting in GraphQL by case expression
parent
79d0b30e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
ee/app/models/ee/vulnerability.rb
ee/app/models/ee/vulnerability.rb
+2
-2
lib/gitlab/graphql/pagination/keyset/order_info.rb
lib/gitlab/graphql/pagination/keyset/order_info.rb
+1
-1
spec/lib/gitlab/graphql/pagination/keyset/order_info_spec.rb
spec/lib/gitlab/graphql/pagination/keyset/order_info_spec.rb
+1
-1
No files found.
ee/app/models/ee/vulnerability.rb
View file @
5a4ac5f6
...
...
@@ -103,8 +103,8 @@ module EE
scope
:order_title_desc
,
->
{
reorder
(
title: :desc
,
id: :desc
)
}
scope
:order_created_at_asc
,
->
{
reorder
(
created_at: :asc
,
id: :desc
)
}
scope
:order_created_at_desc
,
->
{
reorder
(
created_at: :desc
,
id: :desc
)
}
scope
:order_report_type_asc
,
->
{
reorder
(
report_type_order
.
asc
,
id: :desc
)
}
scope
:order_report_type_desc
,
->
{
reorder
(
report_type_order
.
desc
,
id: :desc
)
}
scope
:order_report_type_asc
,
->
{
select
(
*
arel
.
projections
,
report_type_order
.
as
(
'case_order_value'
)).
reorder
(
report_type_order
.
asc
,
id: :desc
)
}
scope
:order_report_type_desc
,
->
{
select
(
*
arel
.
projections
,
report_type_order
.
as
(
'case_order_value'
)).
reorder
(
report_type_order
.
desc
,
id: :desc
)
}
scope
:order_id_desc
,
->
{
reorder
(
id: :desc
)
}
scope
:with_limit
,
->
(
maximum
)
{
limit
(
maximum
)
}
...
...
lib/gitlab/graphql/pagination/keyset/order_info.rb
View file @
5a4ac5f6
...
...
@@ -95,7 +95,7 @@ module Gitlab
elsif
ordering_by_similarity?
(
order_value
)
[
'similarity'
,
order_value
.
direction
,
order_value
.
expr
]
elsif
ordering_by_case?
(
order_value
)
[
order_value
.
expr
.
case
.
name
.
to_s
,
order_value
.
direction
,
order_value
.
expr
]
[
'case_order_value'
,
order_value
.
direction
,
order_value
.
expr
]
else
[
order_value
.
expr
.
name
,
order_value
.
direction
,
nil
]
end
...
...
spec/lib/gitlab/graphql/pagination/keyset/order_info_spec.rb
View file @
5a4ac5f6
...
...
@@ -69,7 +69,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::OrderInfo do
it
'assigns the right attribute name, named function, and direction'
do
expect
(
order_list
.
count
).
to
eq
1
expect
(
order_list
.
first
.
attribute_name
).
to
eq
'
pending_delet
e'
expect
(
order_list
.
first
.
attribute_name
).
to
eq
'
case_order_valu
e'
expect
(
order_list
.
first
.
named_function
).
to
be_kind_of
(
Arel
::
Nodes
::
Case
)
expect
(
order_list
.
first
.
sort_direction
).
to
eq
:asc
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