DB indexer support for searching issues with any assignee

This commit is contained in:
Andreas Svanberg 2025-02-23 20:34:22 +01:00
parent 9a741dfdfa
commit a08f6b0c9e
No known key found for this signature in database
GPG Key ID: 729B051CFFD42F92
2 changed files with 29 additions and 1 deletions

View File

@ -49,12 +49,17 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
return value return value
} }
assigneeID := optional.Some(convertID(options.AssigneeID))
if options.AnyAssigneeOnly {
assigneeID = optional.Some(db.AnyConditionID)
}
opts := &issue_model.IssuesOptions{ opts := &issue_model.IssuesOptions{
Paginator: options.Paginator, Paginator: options.Paginator,
RepoIDs: options.RepoIDs, RepoIDs: options.RepoIDs,
AllPublic: options.AllPublic, AllPublic: options.AllPublic,
RepoCond: nil, RepoCond: nil,
AssigneeID: optional.Some(convertID(options.AssigneeID)), AssigneeID: assigneeID,
PosterID: options.PosterID, PosterID: options.PosterID,
MentionedID: convertID(options.MentionID), MentionedID: convertID(options.MentionID),
ReviewRequestedID: convertID(options.ReviewRequestedID), ReviewRequestedID: convertID(options.ReviewRequestedID),

View File

@ -44,6 +44,7 @@ func TestDBSearchIssues(t *testing.T) {
t.Run("search issues with order", searchIssueWithOrder) t.Run("search issues with order", searchIssueWithOrder)
t.Run("search issues in project", searchIssueInProject) t.Run("search issues in project", searchIssueInProject)
t.Run("search issues with paginator", searchIssueWithPaginator) t.Run("search issues with paginator", searchIssueWithPaginator)
t.Run("search issues with any assignee", searchIssueWithAnyAssignee)
} }
func searchIssueWithKeyword(t *testing.T) { func searchIssueWithKeyword(t *testing.T) {
@ -460,3 +461,25 @@ func searchIssueWithPaginator(t *testing.T) {
assert.Equal(t, test.expectedTotal, total) 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)
}
}