review: addressed review comments

This commit is contained in:
puni9869 committed 2026-06-07 21:31:02 +05:30
1 parent a96cbf6f7b
commit d843bf95ae
3 files changed
+32 -14

No files matched your search

+4 -8
View File
@@ -268,14 +268,10 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
} else { } else {
// "(none)" becomes 0, it means no assignee // "(none)" becomes 0, it means no assignee
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64) assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
if options.AssigneeID == "(none)" { queries = append(queries, bleve.NewDisjunctionQuery(
queries = append(queries, inner_bleve.NumericEqualityQuery(assigneeIDInt64, "assignee_id")) inner_bleve.NumericEqualityQuery(assigneeIDInt64, "assignee_ids"),
} else { inner_bleve.NumericEqualityQuery(assigneeIDInt64, "assignee_id"),
queries = append(queries, bleve.NewDisjunctionQuery( ))
inner_bleve.NumericEqualityQuery(assigneeIDInt64, "assignee_ids"),
inner_bleve.NumericEqualityQuery(assigneeIDInt64, "assignee_id"),
))
}
} }
} }
@@ -16,7 +16,7 @@ import (
"gitea.dev/modules/util" "gitea.dev/modules/util"
) )
const issueIndexerLatestVersion = 3 const issueIndexerLatestVersion = 4
var _ internal.Indexer = &Indexer{} var _ internal.Indexer = &Indexer{}
@@ -58,6 +58,7 @@ const (
"no_project": { "type": "boolean", "index": true }, "no_project": { "type": "boolean", "index": true },
"poster_id": { "type": "integer", "index": true }, "poster_id": { "type": "integer", "index": true },
"assignee_id": { "type": "integer", "index": true }, "assignee_id": { "type": "integer", "index": true },
"assignee_ids": { "type": "integer", "index": true },
"mention_ids": { "type": "integer", "index": true }, "mention_ids": { "type": "integer", "index": true },
"reviewed_ids": { "type": "integer", "index": true }, "reviewed_ids": { "type": "integer", "index": true },
"review_requested_ids": { "type": "integer", "index": true }, "review_requested_ids": { "type": "integer", "index": true },
@@ -179,11 +180,22 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
if options.AssigneeID != "" { if options.AssigneeID != "" {
if options.AssigneeID == "(any)" { if options.AssigneeID == "(any)" {
query.Must(es.NewRangeQuery("assignee_id").Gte(1)) query.Must(es.NewBoolQuery().Should(
es.NewRangeQuery("assignee_id").Gte(1),
es.NewRangeQuery("assignee_ids").Gte(1),
))
} else { } else {
// "(none)" becomes 0, it means no assignee // "(none)" becomes 0, it means no assignee
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64) assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
query.Must(es.TermQuery("assignee_id", assigneeIDInt64)) if options.AssigneeID == "(none)" {
query.Must(es.TermQuery("assignee_id", assigneeIDInt64)).
MustNot(es.NewRangeQuery("assignee_ids").Gte(1))
} else {
query.Must(es.NewBoolQuery().Should(
es.TermQuery("assignee_id", assigneeIDInt64),
es.TermQuery("assignee_ids", assigneeIDInt64),
))
}
} }
} }
@@ -20,7 +20,7 @@ import (
) )
const ( const (
issueIndexerLatestVersion = 5 issueIndexerLatestVersion = 6
// TODO: make this configurable if necessary // TODO: make this configurable if necessary
maxTotalHits = 10000 maxTotalHits = 10000
@@ -75,6 +75,7 @@ func NewIndexer(url, apiKey, indexerName string) *Indexer {
"no_project", "no_project",
"poster_id", "poster_id",
"assignee_id", "assignee_id",
"assignee_ids",
"mention_ids", "mention_ids",
"reviewed_ids", "reviewed_ids",
"review_requested_ids", "review_requested_ids",
@@ -197,11 +198,20 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
if options.AssigneeID != "" { if options.AssigneeID != "" {
if options.AssigneeID == "(any)" { if options.AssigneeID == "(any)" {
query.And(inner_meilisearch.NewFilterGte("assignee_id", 1)) query.And((&inner_meilisearch.FilterOr{}).
Or(inner_meilisearch.NewFilterGte("assignee_id", 1)).
Or(inner_meilisearch.NewFilterGte("assignee_ids", 1)))
} else { } else {
// "(none)" becomes 0, it means no assignee // "(none)" becomes 0, it means no assignee
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64) assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
query.And(inner_meilisearch.NewFilterEq("assignee_id", assigneeIDInt64)) if options.AssigneeID == "(none)" {
query.And(inner_meilisearch.NewFilterEq("assignee_id", assigneeIDInt64)).
And(inner_meilisearch.NewFilterNot(inner_meilisearch.NewFilterGte("assignee_ids", 1)))
} else {
query.And((&inner_meilisearch.FilterOr{}).
Or(inner_meilisearch.NewFilterEq("assignee_id", assigneeIDInt64)).
Or(inner_meilisearch.NewFilterEq("assignee_ids", assigneeIDInt64)))
}
} }
} }