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
89de38a6
Commit
89de38a6
authored
Jul 05, 2021
by
Eulyeon Ko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow sort by popularity for issues via GraphQL
Changelog: added
parent
552576ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
0 deletions
+43
-0
app/graphql/resolvers/issues_resolver.rb
app/graphql/resolvers/issues_resolver.rb
+1
-0
app/graphql/types/issue_sort_enum.rb
app/graphql/types/issue_sort_enum.rb
+2
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+2
-0
spec/graphql/resolvers/issues_resolver_spec.rb
spec/graphql/resolvers/issues_resolver_spec.rb
+38
-0
No files found.
app/graphql/resolvers/issues_resolver.rb
View file @
89de38a6
...
@@ -15,6 +15,7 @@ module Resolvers
...
@@ -15,6 +15,7 @@ module Resolvers
type
Types
::
IssueType
.
connection_type
,
null:
true
type
Types
::
IssueType
.
connection_type
,
null:
true
NON_STABLE_CURSOR_SORTS
=
%i[priority_asc priority_desc
NON_STABLE_CURSOR_SORTS
=
%i[priority_asc priority_desc
popularity_asc popularity_desc
label_priority_asc label_priority_desc
label_priority_asc label_priority_desc
milestone_due_asc milestone_due_desc]
.
freeze
milestone_due_asc milestone_due_desc]
.
freeze
...
...
app/graphql/types/issue_sort_enum.rb
View file @
89de38a6
...
@@ -10,6 +10,8 @@ module Types
...
@@ -10,6 +10,8 @@ module Types
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_ASC'
,
'Severity from less critical to more critical.'
,
value: :severity_asc
value
'SEVERITY_DESC'
,
'Severity from more critical to less critical.'
,
value: :severity_desc
value
'SEVERITY_DESC'
,
'Severity from more critical to less critical.'
,
value: :severity_desc
value
'POPULARITY_ASC'
,
'Number of upvotes (awarded "thumbs up" emoji) by ascending order.'
,
value: :popularity_asc
value
'POPULARITY_DESC'
,
'Number of upvotes (awarded "thumbs up" emoji) by descending order.'
,
value: :popularity_desc
end
end
end
end
...
...
doc/api/graphql/reference/index.md
View file @
89de38a6
...
@@ -14607,6 +14607,8 @@ Values for sorting issues.
...
@@ -14607,6 +14607,8 @@ Values for sorting issues.
|
<a
id=
"issuesortlabel_priority_desc"
></a>
`LABEL_PRIORITY_DESC`
| Label priority by descending order. |
|
<a
id=
"issuesortlabel_priority_desc"
></a>
`LABEL_PRIORITY_DESC`
| Label priority by descending order. |
|
<a
id=
"issuesortmilestone_due_asc"
></a>
`MILESTONE_DUE_ASC`
| Milestone due date by ascending order. |
|
<a
id=
"issuesortmilestone_due_asc"
></a>
`MILESTONE_DUE_ASC`
| Milestone due date by ascending order. |
|
<a
id=
"issuesortmilestone_due_desc"
></a>
`MILESTONE_DUE_DESC`
| Milestone due date by descending order. |
|
<a
id=
"issuesortmilestone_due_desc"
></a>
`MILESTONE_DUE_DESC`
| Milestone due date by descending order. |
|
<a
id=
"issuesortpopularity_asc"
></a>
`POPULARITY_ASC`
| Number of upvotes (awarded "thumbs up" emoji) by ascending order. |
|
<a
id=
"issuesortpopularity_desc"
></a>
`POPULARITY_DESC`
| Number of upvotes (awarded "thumbs up" emoji) by descending order. |
|
<a
id=
"issuesortpriority_asc"
></a>
`PRIORITY_ASC`
| Priority by ascending order. |
|
<a
id=
"issuesortpriority_asc"
></a>
`PRIORITY_ASC`
| Priority by ascending order. |
|
<a
id=
"issuesortpriority_desc"
></a>
`PRIORITY_DESC`
| Priority by descending order. |
|
<a
id=
"issuesortpriority_desc"
></a>
`PRIORITY_DESC`
| Priority by descending order. |
|
<a
id=
"issuesortpublished_asc"
></a>
`PUBLISHED_ASC`
| Published issues shown last. |
|
<a
id=
"issuesortpublished_asc"
></a>
`PUBLISHED_ASC`
| Published issues shown last. |
...
...
spec/graphql/resolvers/issues_resolver_spec.rb
View file @
89de38a6
...
@@ -290,6 +290,44 @@ RSpec.describe Resolvers::IssuesResolver do
...
@@ -290,6 +290,44 @@ RSpec.describe Resolvers::IssuesResolver do
expect
(
resolve_issues
(
sort: :severity_desc
).
to_a
).
to
eq
([
issue_high_severity
,
issue_low_severity
,
issue_no_severity
])
expect
(
resolve_issues
(
sort: :severity_desc
).
to_a
).
to
eq
([
issue_high_severity
,
issue_low_severity
,
issue_no_severity
])
end
end
end
end
context
'when sorting by popularity'
do
let_it_be
(
:project
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:issue1
)
{
create
(
:issue
,
project:
project
)
}
# has one upvote
let_it_be
(
:issue2
)
{
create
(
:issue
,
project:
project
)
}
# has two upvote
let_it_be
(
:issue3
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:issue4
)
{
create
(
:issue
,
project:
project
)
}
# has one upvote
before
do
create
(
:award_emoji
,
:upvote
,
awardable:
issue1
)
create
(
:award_emoji
,
:upvote
,
awardable:
issue2
)
create
(
:award_emoji
,
:upvote
,
awardable:
issue2
)
create
(
:award_emoji
,
:upvote
,
awardable:
issue4
)
end
it
'sorts issues ascending (ties broken by id in desc order)'
,
:aggregate_failures
do
expect
(
issue1
.
id
).
to
be
<
(
issue4
.
id
)
expect
(
resolve_issues
(
sort: :popularity_asc
).
to_a
).
to
eq
([
issue3
,
issue4
,
issue1
,
issue2
])
end
it
'sorts issues descending (ties broken by id in desc order)'
,
:aggregate_failures
do
expect
(
issue1
.
id
).
to
be
<
(
issue4
.
id
)
expect
(
resolve_issues
(
sort: :popularity_desc
).
to_a
).
to
eq
([
issue2
,
issue4
,
issue1
,
issue3
])
end
end
context
'when sorting with non-stable cursors'
do
%i[priority_asc priority_desc
popularity_asc popularity_desc
label_priority_asc label_priority_desc
milestone_due_asc milestone_due_desc]
.
each
do
|
sort_by
|
it
"uses offset-pagination when sorting by
#{
sort_by
}
"
do
resolved
=
resolve_issues
(
sort:
sort_by
)
expect
(
resolved
).
to
be_a
(
::
Gitlab
::
Graphql
::
Pagination
::
OffsetActiveRecordRelationConnection
)
end
end
end
end
end
it
'returns issues user can see'
do
it
'returns issues user can see'
do
...
...
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