mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-20 12:25:10 +02:00
DB indexer support for searching issues with any assignee
This commit is contained in:
parent
9a741dfdfa
commit
a08f6b0c9e
@ -49,12 +49,17 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
|
||||
return value
|
||||
}
|
||||
|
||||
assigneeID := optional.Some(convertID(options.AssigneeID))
|
||||
if options.AnyAssigneeOnly {
|
||||
assigneeID = optional.Some(db.AnyConditionID)
|
||||
}
|
||||
|
||||
opts := &issue_model.IssuesOptions{
|
||||
Paginator: options.Paginator,
|
||||
RepoIDs: options.RepoIDs,
|
||||
AllPublic: options.AllPublic,
|
||||
RepoCond: nil,
|
||||
AssigneeID: optional.Some(convertID(options.AssigneeID)),
|
||||
AssigneeID: assigneeID,
|
||||
PosterID: options.PosterID,
|
||||
MentionedID: convertID(options.MentionID),
|
||||
ReviewRequestedID: convertID(options.ReviewRequestedID),
|
||||
|
@ -44,6 +44,7 @@ func TestDBSearchIssues(t *testing.T) {
|
||||
t.Run("search issues with order", searchIssueWithOrder)
|
||||
t.Run("search issues in project", searchIssueInProject)
|
||||
t.Run("search issues with paginator", searchIssueWithPaginator)
|
||||
t.Run("search issues with any assignee", searchIssueWithAnyAssignee)
|
||||
}
|
||||
|
||||
func searchIssueWithKeyword(t *testing.T) {
|
||||
@ -460,3 +461,25 @@ func searchIssueWithPaginator(t *testing.T) {
|
||||
assert.Equal(t, test.expectedTotal, total)
|
||||
}
|
||||
}
|
||||
|
||||
func searchIssueWithAnyAssignee(t *testing.T) {
|
||||
tests := []struct {
|
||||
opts SearchOptions
|
||||
expectedIDs []int64
|
||||
expectedTotal int64
|
||||
}{
|
||||
{
|
||||
SearchOptions{
|
||||
AnyAssigneeOnly: true,
|
||||
},
|
||||
[]int64{17, 6, 1},
|
||||
3,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
issueIDs, total, err := SearchIssues(t.Context(), &test.opts)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, test.expectedIDs, issueIDs)
|
||||
assert.Equal(t, test.expectedTotal, total)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user