mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-28 16:46:17 +02:00
review: addressed review comments
This commit is contained in:
parent
a96cbf6f7b
commit
d843bf95ae
@ -268,14 +268,10 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
||||
} else {
|
||||
// "(none)" becomes 0, it means no assignee
|
||||
assigneeIDInt64, _ := strconv.ParseInt(options.AssigneeID, 10, 64)
|
||||
if options.AssigneeID == "(none)" {
|
||||
queries = append(queries, inner_bleve.NumericEqualityQuery(assigneeIDInt64, "assignee_id"))
|
||||
} else {
|
||||
queries = append(queries, bleve.NewDisjunctionQuery(
|
||||
inner_bleve.NumericEqualityQuery(assigneeIDInt64, "assignee_ids"),
|
||||
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"
|
||||
)
|
||||
|
||||
const issueIndexerLatestVersion = 3
|
||||
const issueIndexerLatestVersion = 4
|
||||
|
||||
var _ internal.Indexer = &Indexer{}
|
||||
|
||||
@ -58,6 +58,7 @@ const (
|
||||
"no_project": { "type": "boolean", "index": true },
|
||||
"poster_id": { "type": "integer", "index": true },
|
||||
"assignee_id": { "type": "integer", "index": true },
|
||||
"assignee_ids": { "type": "integer", "index": true },
|
||||
"mention_ids": { "type": "integer", "index": true },
|
||||
"reviewed_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 == "(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 {
|
||||
// "(none)" becomes 0, it means no assignee
|
||||
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 (
|
||||
issueIndexerLatestVersion = 5
|
||||
issueIndexerLatestVersion = 6
|
||||
|
||||
// TODO: make this configurable if necessary
|
||||
maxTotalHits = 10000
|
||||
@ -75,6 +75,7 @@ func NewIndexer(url, apiKey, indexerName string) *Indexer {
|
||||
"no_project",
|
||||
"poster_id",
|
||||
"assignee_id",
|
||||
"assignee_ids",
|
||||
"mention_ids",
|
||||
"reviewed_ids",
|
||||
"review_requested_ids",
|
||||
@ -197,11 +198,20 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
||||
|
||||
if options.AssigneeID != "" {
|
||||
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 {
|
||||
// "(none)" becomes 0, it means no assignee
|
||||
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)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user