mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 12:55:23 +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
|
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),
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user