8000 Allow filtering issues by any assignee by asvanberg · Pull Request #33343 · go-gitea/gitea · GitHub
[go: up one dir, main page]

Skip to content

Allow filtering issues by any assignee #33343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bleve indexer support for searching issues with any assignee
  • Loading branch information
asvanberg committed Feb 23, 2025
commit f350f1d8523ca025ddc328359ac6b0dcb97dc6c5
5 changes: 4 additions & 1 deletion modules/indexer/issues/bleve/bleve.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
indexer_internal "code.gitea.io/gitea/modules/indexer/internal"
inner_bleve "code.gitea.io/gitea/modules/indexer/internal/bleve"
"code.gitea.io/gitea/modules/indexer/issues/internal"
"code.gitea.io/gitea/modules/optional"

"github.com/blevesearch/bleve/v2"
"github.com/blevesearch/bleve/v2/analysis/analyzer/custom"
Expand Down Expand Up @@ -236,7 +237,9 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
queries = append(queries, inner_bleve.NumericEqualityQuery(options.PosterID.Value(), "poster_id"))
}

if options.AssigneeID.Has() {
if options.AnyAssigneeOnly {
queries = append(queries, inner_bleve.NumericRangeInclusiveQuery(optional.Some[int64](1), optional.None[int64](), "assignee_id"))
} else if options.AssigneeID.Has() {
queries = append(queries, inner_bleve.NumericEqualityQuery(options.AssigneeID.Value(), "assignee_id"))
}

Expand Down
15 changes: 15 additions & 0 deletions modules/indexer/issues/internal/tests/tests.go
586D
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,21 @@ var cases = []*testIndexerCase{
}
},
},
{
Name: "SearchAnyAssignee",
SearchOptions: &internal.SearchOptions{
AnyAssigneeOnly: true,
},
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
assert.Len(t, result.Hits, 180)
for _, v := range result.Hits {
assert.GreaterOrEqual(t, data[v.ID].AssigneeID, int64(1))
}
assert.Equal(t, countIndexerData(data, func(v *internal.IndexerData) bool {
return v.AssigneeID >= 1
}), result.Total)
},
},
}

type testIndexerCase struct {
Expand Down
0