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
9cbaa6da
Commit
9cbaa6da
authored
Sep 25, 2020
by
Sean Arnold
Committed by
Dmytro Zaporozhets (DZ)
Sep 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for issue resolver sorting
- Specs for EE and CE
parent
58704edf
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
336 additions
and
2 deletions
+336
-2
app/graphql/types/issue_sort_enum.rb
app/graphql/types/issue_sort_enum.rb
+2
-0
app/graphql/types/sort_enum.rb
app/graphql/types/sort_enum.rb
+7
-0
app/models/issue.rb
app/models/issue.rb
+4
-0
changelogs/unreleased/229534-incident-sorting-backend.yml
changelogs/unreleased/229534-incident-sorting-backend.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+100
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+120
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+20
-0
ee/app/graphql/ee/types/issue_sort_enum.rb
ee/app/graphql/ee/types/issue_sort_enum.rb
+2
-0
ee/app/models/ee/issue.rb
ee/app/models/ee/issue.rb
+4
-0
ee/spec/graphql/ee/resolvers/issues_resolver_spec.rb
ee/spec/graphql/ee/resolvers/issues_resolver_spec.rb
+13
-0
ee/spec/graphql/ee/types/issue_sort_enum_spec.rb
ee/spec/graphql/ee/types/issue_sort_enum_spec.rb
+1
-1
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+17
-0
spec/graphql/resolvers/issues_resolver_spec.rb
spec/graphql/resolvers/issues_resolver_spec.rb
+22
-0
spec/graphql/types/issue_sort_enum_spec.rb
spec/graphql/types/issue_sort_enum_spec.rb
+1
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+18
-0
No files found.
app/graphql/types/issue_sort_enum.rb
View file @
9cbaa6da
...
@@ -8,6 +8,8 @@ module Types
...
@@ -8,6 +8,8 @@ module Types
value
'DUE_DATE_ASC'
,
'Due date by ascending order'
,
value: :due_date_asc
value
'DUE_DATE_ASC'
,
'Due date by ascending order'
,
value: :due_date_asc
value
'DUE_DATE_DESC'
,
'Due date by descending order'
,
value: :due_date_desc
value
'DUE_DATE_DESC'
,
'Due date by descending order'
,
value: :due_date_desc
value
'RELATIVE_POSITION_ASC'
,
'Relative position by ascending order'
,
value: :relative_position_asc
value
'RELATIVE_POSITION_ASC'
,
'Relative position by ascending order'
,
value: :relative_position_asc
value
'SEVERITY_ASC'
,
'Severity from less critical to more critical'
,
value: :severity_asc
value
'SEVERITY_DESC'
,
'Severity from more critical to less critical'
,
value: :severity_desc
end
end
end
end
...
...
app/graphql/types/sort_enum.rb
View file @
9cbaa6da
...
@@ -5,9 +5,16 @@ module Types
...
@@ -5,9 +5,16 @@ module Types
graphql_name
'Sort'
graphql_name
'Sort'
description
'Common sort values'
description
'Common sort values'
# Deprecated, as we prefer uppercase enums
# https://gitlab.com/groups/gitlab-org/-/epics/1838
value
'updated_desc'
,
'Updated at descending order'
value
'updated_desc'
,
'Updated at descending order'
value
'updated_asc'
,
'Updated at ascending order'
value
'updated_asc'
,
'Updated at ascending order'
value
'created_desc'
,
'Created at descending order'
value
'created_desc'
,
'Created at descending order'
value
'created_asc'
,
'Created at ascending order'
value
'created_asc'
,
'Created at ascending order'
value
'UPDATED_DESC'
,
'Updated at descending order'
,
value: :updated_desc
value
'UPDATED_ASC'
,
'Updated at ascending order'
,
value: :updated_asc
value
'CREATED_DESC'
,
'Created at descending order'
,
value: :created_desc
value
'CREATED_ASC'
,
'Created at ascending order'
,
value: :created_asc
end
end
end
end
app/models/issue.rb
View file @
9cbaa6da
...
@@ -101,6 +101,8 @@ class Issue < ApplicationRecord
...
@@ -101,6 +101,8 @@ class Issue < ApplicationRecord
scope
:order_relative_position_asc
,
->
{
reorder
(
::
Gitlab
::
Database
.
nulls_last_order
(
'relative_position'
,
'ASC'
))
}
scope
:order_relative_position_asc
,
->
{
reorder
(
::
Gitlab
::
Database
.
nulls_last_order
(
'relative_position'
,
'ASC'
))
}
scope
:order_closed_date_desc
,
->
{
reorder
(
closed_at: :desc
)
}
scope
:order_closed_date_desc
,
->
{
reorder
(
closed_at: :desc
)
}
scope
:order_created_at_desc
,
->
{
reorder
(
created_at: :desc
)
}
scope
:order_created_at_desc
,
->
{
reorder
(
created_at: :desc
)
}
scope
:order_severity_asc
,
->
{
includes
(
:issuable_severity
).
order
(
'issuable_severities.severity ASC NULLS FIRST'
)
}
scope
:order_severity_desc
,
->
{
includes
(
:issuable_severity
).
order
(
'issuable_severities.severity DESC NULLS LAST'
)
}
scope
:preload_associated_models
,
->
{
preload
(
:assignees
,
:labels
,
project: :namespace
)
}
scope
:preload_associated_models
,
->
{
preload
(
:assignees
,
:labels
,
project: :namespace
)
}
scope
:with_web_entity_associations
,
->
{
preload
(
:author
,
:project
)
}
scope
:with_web_entity_associations
,
->
{
preload
(
:author
,
:project
)
}
...
@@ -232,6 +234,8 @@ class Issue < ApplicationRecord
...
@@ -232,6 +234,8 @@ class Issue < ApplicationRecord
when
'due_date'
,
'due_date_asc'
then
order_due_date_asc
.
with_order_id_desc
when
'due_date'
,
'due_date_asc'
then
order_due_date_asc
.
with_order_id_desc
when
'due_date_desc'
then
order_due_date_desc
.
with_order_id_desc
when
'due_date_desc'
then
order_due_date_desc
.
with_order_id_desc
when
'relative_position'
,
'relative_position_asc'
then
order_relative_position_asc
.
with_order_id_desc
when
'relative_position'
,
'relative_position_asc'
then
order_relative_position_asc
.
with_order_id_desc
when
'severity_asc'
then
order_severity_asc
.
with_order_id_desc
when
'severity_desc'
then
order_severity_desc
.
with_order_id_desc
else
else
super
super
end
end
...
...
changelogs/unreleased/229534-incident-sorting-backend.yml
0 → 100644
View file @
9cbaa6da
---
title
:
Add severity and published sorting for incident issues
merge_request
:
42800
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
9cbaa6da
...
@@ -434,6 +434,16 @@ type AlertManagementAlertEdge {
...
@@ -434,6 +434,16 @@ type AlertManagementAlertEdge {
Values for sorting alerts
Values for sorting alerts
"""
"""
enum
AlertManagementAlertSort
{
enum
AlertManagementAlertSort
{
"""
Created
at
ascending
order
"""
CREATED_ASC
"""
Created
at
descending
order
"""
CREATED_DESC
"""
"""
Created
time
by
ascending
order
Created
time
by
ascending
order
"""
"""
...
@@ -494,6 +504,16 @@ enum AlertManagementAlertSort {
...
@@ -494,6 +504,16 @@ enum AlertManagementAlertSort {
"""
"""
STATUS_DESC
STATUS_DESC
"""
Updated
at
ascending
order
"""
UPDATED_ASC
"""
Updated
at
descending
order
"""
UPDATED_DESC
"""
"""
Created
time
by
ascending
order
Created
time
by
ascending
order
"""
"""
...
@@ -8646,6 +8666,16 @@ type IssueSetWeightPayload {
...
@@ -8646,6 +8666,16 @@ type IssueSetWeightPayload {
Values for sorting issues
Values for sorting issues
"""
"""
enum
IssueSort
{
enum
IssueSort
{
"""
Created
at
ascending
order
"""
CREATED_ASC
"""
Created
at
descending
order
"""
CREATED_DESC
"""
"""
Due
date
by
ascending
order
Due
date
by
ascending
order
"""
"""
...
@@ -8686,11 +8716,41 @@ enum IssueSort {
...
@@ -8686,11 +8716,41 @@ enum IssueSort {
"""
"""
PRIORITY_DESC
PRIORITY_DESC
"""
Published
issues
shown
last
"""
PUBLISHED_ASC
"""
Published
issues
shown
first
"""
PUBLISHED_DESC
"""
"""
Relative
position
by
ascending
order
Relative
position
by
ascending
order
"""
"""
RELATIVE_POSITION_ASC
RELATIVE_POSITION_ASC
"""
Severity
from
less
critical
to
more
critical
"""
SEVERITY_ASC
"""
Severity
from
more
critical
to
less
critical
"""
SEVERITY_DESC
"""
Updated
at
ascending
order
"""
UPDATED_ASC
"""
Updated
at
descending
order
"""
UPDATED_DESC
"""
"""
Weight
by
ascending
order
Weight
by
ascending
order
"""
"""
...
@@ -10397,6 +10457,16 @@ type MergeRequestSetWipPayload {
...
@@ -10397,6 +10457,16 @@ type MergeRequestSetWipPayload {
Values for sorting merge requests
Values for sorting merge requests
"""
"""
enum
MergeRequestSort
{
enum
MergeRequestSort
{
"""
Created
at
ascending
order
"""
CREATED_ASC
"""
Created
at
descending
order
"""
CREATED_DESC
"""
"""
Label
priority
by
ascending
order
Label
priority
by
ascending
order
"""
"""
...
@@ -10437,6 +10507,16 @@ enum MergeRequestSort {
...
@@ -10437,6 +10507,16 @@ enum MergeRequestSort {
"""
"""
PRIORITY_DESC
PRIORITY_DESC
"""
Updated
at
ascending
order
"""
UPDATED_ASC
"""
Updated
at
descending
order
"""
UPDATED_DESC
"""
"""
Created
at
ascending
order
Created
at
ascending
order
"""
"""
...
@@ -16584,6 +16664,26 @@ type SnippetPermissions {
...
@@ -16584,6 +16664,26 @@ type SnippetPermissions {
Common sort values
Common sort values
"""
"""
enum
Sort
{
enum
Sort
{
"""
Created
at
ascending
order
"""
CREATED_ASC
"""
Created
at
descending
order
"""
CREATED_DESC
"""
Updated
at
ascending
order
"""
UPDATED_ASC
"""
Updated
at
descending
order
"""
UPDATED_DESC
"""
"""
Created
at
ascending
order
Created
at
ascending
order
"""
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
9cbaa6da
...
@@ -1248,6 +1248,30 @@
...
@@ -1248,6 +1248,30 @@
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
},
{
"name": "UPDATED_DESC",
"description": "Updated at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "UPDATED_ASC",
"description": "Updated at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_DESC",
"description": "Created at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_ASC",
"description": "Created at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
{
"name": "STARTED_AT_ASC",
"name": "STARTED_AT_ASC",
"description": "Start time by ascending order",
"description": "Start time by ascending order",
...
@@ -23935,6 +23959,30 @@
...
@@ -23935,6 +23959,30 @@
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
},
{
"name": "UPDATED_DESC",
"description": "Updated at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "UPDATED_ASC",
"description": "Updated at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_DESC",
"description": "Created at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_ASC",
"description": "Created at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
{
"name": "PRIORITY_ASC",
"name": "PRIORITY_ASC",
"description": "Priority by ascending order",
"description": "Priority by ascending order",
...
@@ -23989,6 +24037,18 @@
...
@@ -23989,6 +24037,18 @@
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
},
{
"name": "SEVERITY_ASC",
"description": "Severity from less critical to more critical",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "SEVERITY_DESC",
"description": "Severity from more critical to less critical",
"isDeprecated": false,
"deprecationReason": null
},
{
{
"name": "WEIGHT_ASC",
"name": "WEIGHT_ASC",
"description": "Weight by ascending order",
"description": "Weight by ascending order",
...
@@ -24000,6 +24060,18 @@
...
@@ -24000,6 +24060,18 @@
"description": "Weight by descending order",
"description": "Weight by descending order",
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
{
"name": "PUBLISHED_ASC",
"description": "Published issues shown last",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "PUBLISHED_DESC",
"description": "Published issues shown first",
"isDeprecated": false,
"deprecationReason": null
}
}
],
],
"possibleTypes": null
"possibleTypes": null
...
@@ -28947,6 +29019,30 @@
...
@@ -28947,6 +29019,30 @@
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
},
{
"name": "UPDATED_DESC",
"description": "Updated at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "UPDATED_ASC",
"description": "Updated at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_DESC",
"description": "Created at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_ASC",
"description": "Created at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
{
"name": "PRIORITY_ASC",
"name": "PRIORITY_ASC",
"description": "Priority by ascending order",
"description": "Priority by ascending order",
...
@@ -48619,6 +48715,30 @@
...
@@ -48619,6 +48715,30 @@
"description": "Created at ascending order",
"description": "Created at ascending order",
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
{
"name": "UPDATED_DESC",
"description": "Updated at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "UPDATED_ASC",
"description": "Updated at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_DESC",
"description": "Created at descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CREATED_ASC",
"description": "Created at ascending order",
"isDeprecated": false,
"deprecationReason": null
}
}
],
],
"possibleTypes": null
"possibleTypes": null
doc/api/graphql/reference/index.md
View file @
9cbaa6da
...
@@ -2911,6 +2911,8 @@ Values for sorting alerts.
...
@@ -2911,6 +2911,8 @@ Values for sorting alerts.
| Value | Description |
| Value | Description |
| ----- | ----------- |
| ----- | ----------- |
|
`CREATED_ASC`
| Created at ascending order |
|
`CREATED_DESC`
| Created at descending order |
|
`CREATED_TIME_ASC`
| Created time by ascending order |
|
`CREATED_TIME_ASC`
| Created time by ascending order |
|
`CREATED_TIME_DESC`
| Created time by descending order |
|
`CREATED_TIME_DESC`
| Created time by descending order |
|
`ENDED_AT_ASC`
| End time by ascending order |
|
`ENDED_AT_ASC`
| End time by ascending order |
...
@@ -2923,6 +2925,8 @@ Values for sorting alerts.
...
@@ -2923,6 +2925,8 @@ Values for sorting alerts.
|
`STARTED_AT_DESC`
| Start time by descending order |
|
`STARTED_AT_DESC`
| Start time by descending order |
|
`STATUS_ASC`
| Status by order: Ignored > Resolved > Acknowledged > Triggered |
|
`STATUS_ASC`
| Status by order: Ignored > Resolved > Acknowledged > Triggered |
|
`STATUS_DESC`
| Status by order: Triggered > Acknowledged > Resolved > Ignored |
|
`STATUS_DESC`
| Status by order: Triggered > Acknowledged > Resolved > Ignored |
|
`UPDATED_ASC`
| Updated at ascending order |
|
`UPDATED_DESC`
| Updated at descending order |
|
`UPDATED_TIME_ASC`
| Created time by ascending order |
|
`UPDATED_TIME_ASC`
| Created time by ascending order |
|
`UPDATED_TIME_DESC`
| Created time by descending order |
|
`UPDATED_TIME_DESC`
| Created time by descending order |
|
`created_asc`
| Created at ascending order |
|
`created_asc`
| Created at ascending order |
...
@@ -3146,6 +3150,8 @@ Values for sorting issues.
...
@@ -3146,6 +3150,8 @@ Values for sorting issues.
| Value | Description |
| Value | Description |
| ----- | ----------- |
| ----- | ----------- |
|
`CREATED_ASC`
| Created at ascending order |
|
`CREATED_DESC`
| Created at descending order |
|
`DUE_DATE_ASC`
| Due date by ascending order |
|
`DUE_DATE_ASC`
| Due date by ascending order |
|
`DUE_DATE_DESC`
| Due date by descending order |
|
`DUE_DATE_DESC`
| Due date by descending order |
|
`LABEL_PRIORITY_ASC`
| Label priority by ascending order |
|
`LABEL_PRIORITY_ASC`
| Label priority by ascending order |
...
@@ -3154,7 +3160,13 @@ Values for sorting issues.
...
@@ -3154,7 +3160,13 @@ Values for sorting issues.
|
`MILESTONE_DUE_DESC`
| Milestone due date by descending order |
|
`MILESTONE_DUE_DESC`
| Milestone due date by descending order |
|
`PRIORITY_ASC`
| Priority by ascending order |
|
`PRIORITY_ASC`
| Priority by ascending order |
|
`PRIORITY_DESC`
| Priority by descending order |
|
`PRIORITY_DESC`
| Priority by descending order |
|
`PUBLISHED_ASC`
| Published issues shown last |
|
`PUBLISHED_DESC`
| Published issues shown first |
|
`RELATIVE_POSITION_ASC`
| Relative position by ascending order |
|
`RELATIVE_POSITION_ASC`
| Relative position by ascending order |
|
`SEVERITY_ASC`
| Severity from less critical to more critical |
|
`SEVERITY_DESC`
| Severity from more critical to less critical |
|
`UPDATED_ASC`
| Updated at ascending order |
|
`UPDATED_DESC`
| Updated at descending order |
|
`WEIGHT_ASC`
| Weight by ascending order |
|
`WEIGHT_ASC`
| Weight by ascending order |
|
`WEIGHT_DESC`
| Weight by descending order |
|
`WEIGHT_DESC`
| Weight by descending order |
|
`created_asc`
| Created at ascending order |
|
`created_asc`
| Created at ascending order |
...
@@ -3224,6 +3236,8 @@ Values for sorting merge requests.
...
@@ -3224,6 +3236,8 @@ Values for sorting merge requests.
| Value | Description |
| Value | Description |
| ----- | ----------- |
| ----- | ----------- |
|
`CREATED_ASC`
| Created at ascending order |
|
`CREATED_DESC`
| Created at descending order |
|
`LABEL_PRIORITY_ASC`
| Label priority by ascending order |
|
`LABEL_PRIORITY_ASC`
| Label priority by ascending order |
|
`LABEL_PRIORITY_DESC`
| Label priority by descending order |
|
`LABEL_PRIORITY_DESC`
| Label priority by descending order |
|
`MERGED_AT_ASC`
| Merge time by ascending order |
|
`MERGED_AT_ASC`
| Merge time by ascending order |
...
@@ -3232,6 +3246,8 @@ Values for sorting merge requests.
...
@@ -3232,6 +3246,8 @@ Values for sorting merge requests.
|
`MILESTONE_DUE_DESC`
| Milestone due date by descending order |
|
`MILESTONE_DUE_DESC`
| Milestone due date by descending order |
|
`PRIORITY_ASC`
| Priority by ascending order |
|
`PRIORITY_ASC`
| Priority by ascending order |
|
`PRIORITY_DESC`
| Priority by descending order |
|
`PRIORITY_DESC`
| Priority by descending order |
|
`UPDATED_ASC`
| Updated at ascending order |
|
`UPDATED_DESC`
| Updated at descending order |
|
`created_asc`
| Created at ascending order |
|
`created_asc`
| Created at ascending order |
|
`created_desc`
| Created at descending order |
|
`created_desc`
| Created at descending order |
|
`updated_asc`
| Updated at ascending order |
|
`updated_asc`
| Updated at ascending order |
...
@@ -3460,6 +3476,10 @@ Common sort values.
...
@@ -3460,6 +3476,10 @@ Common sort values.
| Value | Description |
| Value | Description |
| ----- | ----------- |
| ----- | ----------- |
|
`CREATED_ASC`
| Created at ascending order |
|
`CREATED_DESC`
| Created at descending order |
|
`UPDATED_ASC`
| Updated at ascending order |
|
`UPDATED_DESC`
| Updated at descending order |
|
`created_asc`
| Created at ascending order |
|
`created_asc`
| Created at ascending order |
|
`created_desc`
| Created at descending order |
|
`created_desc`
| Created at descending order |
|
`updated_asc`
| Updated at ascending order |
|
`updated_asc`
| Updated at ascending order |
...
...
ee/app/graphql/ee/types/issue_sort_enum.rb
View file @
9cbaa6da
...
@@ -8,6 +8,8 @@ module EE
...
@@ -8,6 +8,8 @@ module EE
prepended
do
prepended
do
value
'WEIGHT_ASC'
,
'Weight by ascending order'
,
value:
'weight_asc'
value
'WEIGHT_ASC'
,
'Weight by ascending order'
,
value:
'weight_asc'
value
'WEIGHT_DESC'
,
'Weight by descending order'
,
value:
'weight_desc'
value
'WEIGHT_DESC'
,
'Weight by descending order'
,
value:
'weight_desc'
value
'PUBLISHED_ASC'
,
'Published issues shown last'
,
value: :published_asc
value
'PUBLISHED_DESC'
,
'Published issues shown first'
,
value: :published_desc
end
end
end
end
end
end
...
...
ee/app/models/ee/issue.rb
View file @
9cbaa6da
...
@@ -21,6 +21,8 @@ module EE
...
@@ -21,6 +21,8 @@ module EE
scope
:order_blocking_issues_desc
,
->
{
reorder
(
blocking_issues_count: :desc
)
}
scope
:order_blocking_issues_desc
,
->
{
reorder
(
blocking_issues_count: :desc
)
}
scope
:order_weight_desc
,
->
{
reorder
::
Gitlab
::
Database
.
nulls_last_order
(
'weight'
,
'DESC'
)
}
scope
:order_weight_desc
,
->
{
reorder
::
Gitlab
::
Database
.
nulls_last_order
(
'weight'
,
'DESC'
)
}
scope
:order_weight_asc
,
->
{
reorder
::
Gitlab
::
Database
.
nulls_last_order
(
'weight'
)
}
scope
:order_weight_asc
,
->
{
reorder
::
Gitlab
::
Database
.
nulls_last_order
(
'weight'
)
}
scope
:order_status_page_published_first
,
->
{
includes
(
:status_page_published_incident
).
order
(
'status_page_published_incidents.id ASC NULLS LAST'
)
}
scope
:order_status_page_published_last
,
->
{
includes
(
:status_page_published_incident
).
order
(
'status_page_published_incidents.id ASC NULLS FIRST'
)
}
scope
:no_epic
,
->
{
left_outer_joins
(
:epic_issue
).
where
(
epic_issues:
{
epic_id:
nil
})
}
scope
:no_epic
,
->
{
left_outer_joins
(
:epic_issue
).
where
(
epic_issues:
{
epic_id:
nil
})
}
scope
:any_epic
,
->
{
joins
(
:epic_issue
)
}
scope
:any_epic
,
->
{
joins
(
:epic_issue
)
}
scope
:in_epics
,
->
(
epics
)
{
joins
(
:epic_issue
).
where
(
epic_issues:
{
epic_id:
epics
})
}
scope
:in_epics
,
->
(
epics
)
{
joins
(
:epic_issue
).
where
(
epic_issues:
{
epic_id:
epics
})
}
...
@@ -184,6 +186,8 @@ module EE
...
@@ -184,6 +186,8 @@ module EE
when
'blocking_issues_desc'
then
order_blocking_issues_desc
.
with_order_id_desc
when
'blocking_issues_desc'
then
order_blocking_issues_desc
.
with_order_id_desc
when
'weight'
,
'weight_asc'
then
order_weight_asc
.
with_order_id_desc
when
'weight'
,
'weight_asc'
then
order_weight_asc
.
with_order_id_desc
when
'weight_desc'
then
order_weight_desc
.
with_order_id_desc
when
'weight_desc'
then
order_weight_desc
.
with_order_id_desc
when
'published_asc'
then
order_status_page_published_last
.
with_order_id_desc
when
'published_desc'
then
order_status_page_published_first
.
with_order_id_desc
else
else
super
super
end
end
...
...
ee/spec/graphql/ee/resolvers/issues_resolver_spec.rb
View file @
9cbaa6da
...
@@ -30,6 +30,19 @@ RSpec.describe Resolvers::IssuesResolver do
...
@@ -30,6 +30,19 @@ RSpec.describe Resolvers::IssuesResolver do
expect
(
resolve_issues
(
sort: :weight_desc
)).
to
eq
[
weight_issue1
,
weight_issue3
,
weight_issue4
,
weight_issue2
]
expect
(
resolve_issues
(
sort: :weight_desc
)).
to
eq
[
weight_issue1
,
weight_issue3
,
weight_issue4
,
weight_issue2
]
end
end
end
end
context
'when sorting by published'
do
let_it_be
(
:not_published
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:published
)
{
create
(
:issue
,
:published
,
project:
project
)
}
it
'sorts issues ascending'
do
expect
(
resolve_issues
(
sort: :published_asc
)).
to
eq
[
not_published
,
published
]
end
it
'sorts issues descending'
do
expect
(
resolve_issues
(
sort: :published_desc
)).
to
eq
[
published
,
not_published
]
end
end
end
end
describe
'filtering by iteration'
do
describe
'filtering by iteration'
do
...
...
ee/spec/graphql/ee/types/issue_sort_enum_spec.rb
View file @
9cbaa6da
...
@@ -8,6 +8,6 @@ RSpec.describe GitlabSchema.types['IssueSort'] do
...
@@ -8,6 +8,6 @@ RSpec.describe GitlabSchema.types['IssueSort'] do
it_behaves_like
'common sort values'
it_behaves_like
'common sort values'
it
'exposes all the existing EE issue sort values'
do
it
'exposes all the existing EE issue sort values'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[WEIGHT_ASC WEIGHT_DESC]
)
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[WEIGHT_ASC WEIGHT_DESC
PUBLISHED_ASC PUBLISHED_DESC
]
)
end
end
end
end
ee/spec/models/issue_spec.rb
View file @
9cbaa6da
...
@@ -182,6 +182,23 @@ RSpec.describe Issue do
...
@@ -182,6 +182,23 @@ RSpec.describe Issue do
end
end
end
end
end
end
context
'status page published'
do
let_it_be
(
:not_published
)
{
create
(
:issue
)
}
let_it_be
(
:published
)
{
create
(
:issue
,
:published
)
}
describe
'.order_status_page_published_first'
do
subject
{
described_class
.
order_status_page_published_first
}
it
{
is_expected
.
to
eq
([
published
,
not_published
])
}
end
describe
'.order_status_page_published_last'
do
subject
{
described_class
.
order_status_page_published_last
}
it
{
is_expected
.
to
eq
([
not_published
,
published
])
}
end
end
end
end
describe
'validations'
do
describe
'validations'
do
...
...
spec/graphql/resolvers/issues_resolver_spec.rb
View file @
9cbaa6da
...
@@ -223,6 +223,21 @@ RSpec.describe Resolvers::IssuesResolver do
...
@@ -223,6 +223,21 @@ RSpec.describe Resolvers::IssuesResolver do
expect
(
resolve_issues
(
sort: :milestone_due_desc
).
items
).
to
eq
([
milestone_issue3
,
milestone_issue2
,
milestone_issue1
])
expect
(
resolve_issues
(
sort: :milestone_due_desc
).
items
).
to
eq
([
milestone_issue3
,
milestone_issue2
,
milestone_issue1
])
end
end
end
end
context
'when sorting by severity'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:issue_high_severity
)
{
create_issue_with_severity
(
project
,
severity: :high
)
}
let_it_be
(
:issue_low_severity
)
{
create_issue_with_severity
(
project
,
severity: :low
)
}
let_it_be
(
:issue_no_severity
)
{
create
(
:incident
,
project:
project
)
}
it
'sorts issues ascending'
do
expect
(
resolve_issues
(
sort: :severity_asc
)).
to
eq
([
issue_no_severity
,
issue_low_severity
,
issue_high_severity
])
end
it
'sorts issues descending'
do
expect
(
resolve_issues
(
sort: :severity_desc
)).
to
eq
([
issue_high_severity
,
issue_low_severity
,
issue_no_severity
])
end
end
end
end
it
'returns issues user can see'
do
it
'returns issues user can see'
do
...
@@ -308,6 +323,13 @@ RSpec.describe Resolvers::IssuesResolver do
...
@@ -308,6 +323,13 @@ RSpec.describe Resolvers::IssuesResolver do
expect
(
field
.
to_graphql
.
complexity
.
call
({},
{
labelName:
'foo'
},
1
)).
to
eq
8
expect
(
field
.
to_graphql
.
complexity
.
call
({},
{
labelName:
'foo'
},
1
)).
to
eq
8
end
end
def
create_issue_with_severity
(
project
,
severity
:)
issue
=
create
(
:incident
,
project:
project
)
create
(
:issuable_severity
,
issue:
issue
,
severity:
severity
)
issue
end
def
resolve_issues
(
args
=
{},
context
=
{
current_user:
current_user
})
def
resolve_issues
(
args
=
{},
context
=
{
current_user:
current_user
})
resolve
(
described_class
,
obj:
project
,
args:
args
,
ctx:
context
)
resolve
(
described_class
,
obj:
project
,
args:
args
,
ctx:
context
)
end
end
...
...
spec/graphql/types/issue_sort_enum_spec.rb
View file @
9cbaa6da
...
@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['IssueSort'] do
...
@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['IssueSort'] do
it
'exposes all the existing issue sort values'
do
it
'exposes all the existing issue sort values'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[DUE_DATE_ASC DUE_DATE_DESC RELATIVE_POSITION_ASC]
*
%w[DUE_DATE_ASC DUE_DATE_DESC RELATIVE_POSITION_ASC
SEVERITY_ASC SEVERITY_DESC
]
)
)
end
end
end
end
spec/models/issue_spec.rb
View file @
9cbaa6da
...
@@ -146,6 +146,24 @@ RSpec.describe Issue do
...
@@ -146,6 +146,24 @@ RSpec.describe Issue do
end
end
end
end
describe
'.order_severity'
do
let_it_be
(
:issue_high_severity
)
{
create
(
:issuable_severity
,
severity: :high
).
issue
}
let_it_be
(
:issue_low_severity
)
{
create
(
:issuable_severity
,
severity: :low
).
issue
}
let_it_be
(
:issue_no_severity
)
{
create
(
:incident
)
}
context
'sorting ascending'
do
subject
{
described_class
.
order_severity_asc
}
it
{
is_expected
.
to
eq
([
issue_no_severity
,
issue_low_severity
,
issue_high_severity
])
}
end
context
'sorting descending'
do
subject
{
described_class
.
order_severity_desc
}
it
{
is_expected
.
to
eq
([
issue_high_severity
,
issue_low_severity
,
issue_no_severity
])
}
end
end
describe
'#order_by_position_and_priority'
do
describe
'#order_by_position_and_priority'
do
let
(
:project
)
{
reusable_project
}
let
(
:project
)
{
reusable_project
}
let
(
:p1
)
{
create
(
:label
,
title:
'P1'
,
project:
project
,
priority:
1
)
}
let
(
:p1
)
{
create
(
:label
,
title:
'P1'
,
project:
project
,
priority:
1
)
}
...
...
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