Refactor to use optional.Option for issue index search option (#29739)
Signed-off-by: 6543 <6543@obermui.de> (cherry picked from commit 7fd0a5b276aadcf88dcc012fcd364fe160a58810)
This commit is contained in:
parent
f98211f13a
commit
d9103449b3
12 changed files with 178 additions and 225 deletions
|
@ -4,6 +4,8 @@
|
||||||
package bleve
|
package bleve
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.gitea.io/gitea/modules/optional"
|
||||||
|
|
||||||
"github.com/blevesearch/bleve/v2"
|
"github.com/blevesearch/bleve/v2"
|
||||||
"github.com/blevesearch/bleve/v2/search/query"
|
"github.com/blevesearch/bleve/v2/search/query"
|
||||||
)
|
)
|
||||||
|
@ -39,18 +41,18 @@ func BoolFieldQuery(value bool, field string) *query.BoolFieldQuery {
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
func NumericRangeInclusiveQuery(min, max *int64, field string) *query.NumericRangeQuery {
|
func NumericRangeInclusiveQuery(min, max optional.Option[int64], field string) *query.NumericRangeQuery {
|
||||||
var minF, maxF *float64
|
var minF, maxF *float64
|
||||||
var minI, maxI *bool
|
var minI, maxI *bool
|
||||||
if min != nil {
|
if min.Has() {
|
||||||
minF = new(float64)
|
minF = new(float64)
|
||||||
*minF = float64(*min)
|
*minF = float64(min.Value())
|
||||||
minI = new(bool)
|
minI = new(bool)
|
||||||
*minI = true
|
*minI = true
|
||||||
}
|
}
|
||||||
if max != nil {
|
if max.Has() {
|
||||||
maxF = new(float64)
|
maxF = new(float64)
|
||||||
*maxF = float64(*max)
|
*maxF = float64(max.Value())
|
||||||
maxI = new(bool)
|
maxI = new(bool)
|
||||||
*maxI = true
|
*maxI = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,38 +224,41 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
||||||
queries = append(queries, bleve.NewDisjunctionQuery(milestoneQueries...))
|
queries = append(queries, bleve.NewDisjunctionQuery(milestoneQueries...))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ProjectID != nil {
|
if options.ProjectID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ProjectID, "project_id"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ProjectID.Value(), "project_id"))
|
||||||
}
|
}
|
||||||
if options.ProjectBoardID != nil {
|
if options.ProjectBoardID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ProjectBoardID, "project_board_id"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ProjectBoardID.Value(), "project_board_id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.PosterID != nil {
|
if options.PosterID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.PosterID, "poster_id"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.PosterID.Value(), "poster_id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.AssigneeID != nil {
|
if options.AssigneeID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.AssigneeID, "assignee_id"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.AssigneeID.Value(), "assignee_id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.MentionID != nil {
|
if options.MentionID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.MentionID, "mention_ids"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.MentionID.Value(), "mention_ids"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ReviewedID != nil {
|
if options.ReviewedID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ReviewedID, "reviewed_ids"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ReviewedID.Value(), "reviewed_ids"))
|
||||||
}
|
}
|
||||||
if options.ReviewRequestedID != nil {
|
if options.ReviewRequestedID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ReviewRequestedID, "review_requested_ids"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ReviewRequestedID.Value(), "review_requested_ids"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.SubscriberID != nil {
|
if options.SubscriberID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.SubscriberID, "subscriber_ids"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.SubscriberID.Value(), "subscriber_ids"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.UpdatedAfterUnix != nil || options.UpdatedBeforeUnix != nil {
|
if options.UpdatedAfterUnix.Has() || options.UpdatedBeforeUnix.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericRangeInclusiveQuery(options.UpdatedAfterUnix, options.UpdatedBeforeUnix, "updated_unix"))
|
queries = append(queries, inner_bleve.NumericRangeInclusiveQuery(
|
||||||
|
options.UpdatedAfterUnix,
|
||||||
|
options.UpdatedBeforeUnix,
|
||||||
|
"updated_unix"))
|
||||||
}
|
}
|
||||||
|
|
||||||
var indexerQuery query.Query = bleve.NewConjunctionQuery(queries...)
|
var indexerQuery query.Query = bleve.NewConjunctionQuery(queries...)
|
||||||
|
|
|
@ -15,22 +15,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_model.IssuesOptions, error) {
|
func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_model.IssuesOptions, error) {
|
||||||
// See the comment of issues_model.SearchOptions for the reason why we need to convert
|
|
||||||
convertID := func(id *int64) int64 {
|
|
||||||
if id == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if *id == 0 {
|
|
||||||
return db.NoConditionID
|
|
||||||
}
|
|
||||||
return *id
|
|
||||||
}
|
|
||||||
convertInt64 := func(i *int64) int64 {
|
|
||||||
if i == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return *i
|
|
||||||
}
|
|
||||||
var sortType string
|
var sortType string
|
||||||
switch options.SortBy {
|
switch options.SortBy {
|
||||||
case internal.SortByCreatedAsc:
|
case internal.SortByCreatedAsc:
|
||||||
|
@ -53,6 +37,18 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
|
||||||
sortType = "newest"
|
sortType = "newest"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See the comment of issues_model.SearchOptions for the reason why we need to convert
|
||||||
|
convertID := func(id optional.Option[int64]) int64 {
|
||||||
|
if !id.Has() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
value := id.Value()
|
||||||
|
if value == 0 {
|
||||||
|
return db.NoConditionID
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
opts := &issue_model.IssuesOptions{
|
opts := &issue_model.IssuesOptions{
|
||||||
Paginator: options.Paginator,
|
Paginator: options.Paginator,
|
||||||
RepoIDs: options.RepoIDs,
|
RepoIDs: options.RepoIDs,
|
||||||
|
@ -73,8 +69,8 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
|
||||||
IncludeMilestones: nil,
|
IncludeMilestones: nil,
|
||||||
SortType: sortType,
|
SortType: sortType,
|
||||||
IssueIDs: nil,
|
IssueIDs: nil,
|
||||||
UpdatedAfterUnix: convertInt64(options.UpdatedAfterUnix),
|
UpdatedAfterUnix: options.UpdatedAfterUnix.Value(),
|
||||||
UpdatedBeforeUnix: convertInt64(options.UpdatedBeforeUnix),
|
UpdatedBeforeUnix: options.UpdatedBeforeUnix.Value(),
|
||||||
PriorityRepoID: 0,
|
PriorityRepoID: 0,
|
||||||
IsArchived: optional.None[bool](),
|
IsArchived: optional.None[bool](),
|
||||||
Org: nil,
|
Org: nil,
|
||||||
|
|
|
@ -6,6 +6,7 @@ package issues
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
|
"code.gitea.io/gitea/modules/optional"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOptions {
|
func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOptions {
|
||||||
|
@ -38,13 +39,12 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
|
||||||
}
|
}
|
||||||
|
|
||||||
// See the comment of issues_model.SearchOptions for the reason why we need to convert
|
// See the comment of issues_model.SearchOptions for the reason why we need to convert
|
||||||
convertID := func(id int64) *int64 {
|
convertID := func(id int64) optional.Option[int64] {
|
||||||
if id > 0 {
|
if id > 0 {
|
||||||
return &id
|
return optional.Some(id)
|
||||||
}
|
}
|
||||||
if id == db.NoConditionID {
|
if id == db.NoConditionID {
|
||||||
var zero int64
|
return optional.None[int64]()
|
||||||
return &zero
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,10 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
|
||||||
searchOpt.SubscriberID = convertID(opts.SubscriberID)
|
searchOpt.SubscriberID = convertID(opts.SubscriberID)
|
||||||
|
|
||||||
if opts.UpdatedAfterUnix > 0 {
|
if opts.UpdatedAfterUnix > 0 {
|
||||||
searchOpt.UpdatedAfterUnix = &opts.UpdatedAfterUnix
|
searchOpt.UpdatedAfterUnix = optional.Some(opts.UpdatedAfterUnix)
|
||||||
}
|
}
|
||||||
if opts.UpdatedBeforeUnix > 0 {
|
if opts.UpdatedBeforeUnix > 0 {
|
||||||
searchOpt.UpdatedBeforeUnix = &opts.UpdatedBeforeUnix
|
searchOpt.UpdatedBeforeUnix = optional.Some(opts.UpdatedBeforeUnix)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchOpt.Paginator = opts.Paginator
|
searchOpt.Paginator = opts.Paginator
|
||||||
|
|
|
@ -195,43 +195,43 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
||||||
query.Must(elastic.NewTermsQuery("milestone_id", toAnySlice(options.MilestoneIDs)...))
|
query.Must(elastic.NewTermsQuery("milestone_id", toAnySlice(options.MilestoneIDs)...))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ProjectID != nil {
|
if options.ProjectID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("project_id", *options.ProjectID))
|
query.Must(elastic.NewTermQuery("project_id", options.ProjectID.Value()))
|
||||||
}
|
}
|
||||||
if options.ProjectBoardID != nil {
|
if options.ProjectBoardID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("project_board_id", *options.ProjectBoardID))
|
query.Must(elastic.NewTermQuery("project_board_id", options.ProjectBoardID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.PosterID != nil {
|
if options.PosterID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("poster_id", *options.PosterID))
|
query.Must(elastic.NewTermQuery("poster_id", options.PosterID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.AssigneeID != nil {
|
if options.AssigneeID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("assignee_id", *options.AssigneeID))
|
query.Must(elastic.NewTermQuery("assignee_id", options.AssigneeID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.MentionID != nil {
|
if options.MentionID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("mention_ids", *options.MentionID))
|
query.Must(elastic.NewTermQuery("mention_ids", options.MentionID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ReviewedID != nil {
|
if options.ReviewedID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("reviewed_ids", *options.ReviewedID))
|
query.Must(elastic.NewTermQuery("reviewed_ids", options.ReviewedID.Value()))
|
||||||
}
|
}
|
||||||
if options.ReviewRequestedID != nil {
|
if options.ReviewRequestedID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("review_requested_ids", *options.ReviewRequestedID))
|
query.Must(elastic.NewTermQuery("review_requested_ids", options.ReviewRequestedID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.SubscriberID != nil {
|
if options.SubscriberID.Has() {
|
||||||
query.Must(elastic.NewTermQuery("subscriber_ids", *options.SubscriberID))
|
query.Must(elastic.NewTermQuery("subscriber_ids", options.SubscriberID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.UpdatedAfterUnix != nil || options.UpdatedBeforeUnix != nil {
|
if options.UpdatedAfterUnix.Has() || options.UpdatedBeforeUnix.Has() {
|
||||||
q := elastic.NewRangeQuery("updated_unix")
|
q := elastic.NewRangeQuery("updated_unix")
|
||||||
if options.UpdatedAfterUnix != nil {
|
if options.UpdatedAfterUnix.Has() {
|
||||||
q.Gte(*options.UpdatedAfterUnix)
|
q.Gte(options.UpdatedAfterUnix.Value())
|
||||||
}
|
}
|
||||||
if options.UpdatedBeforeUnix != nil {
|
if options.UpdatedBeforeUnix.Has() {
|
||||||
q.Lte(*options.UpdatedBeforeUnix)
|
q.Lte(options.UpdatedBeforeUnix.Value())
|
||||||
}
|
}
|
||||||
query.Must(q)
|
query.Must(q)
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,63 +134,60 @@ func searchIssueInRepo(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchIssueByID(t *testing.T) {
|
func searchIssueByID(t *testing.T) {
|
||||||
int64Pointer := func(x int64) *int64 {
|
|
||||||
return &x
|
|
||||||
}
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
opts SearchOptions
|
opts SearchOptions
|
||||||
expectedIDs []int64
|
expectedIDs []int64
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
PosterID: int64Pointer(1),
|
PosterID: optional.Some(int64(1)),
|
||||||
},
|
},
|
||||||
[]int64{11, 6, 3, 2, 1},
|
expectedIDs: []int64{11, 6, 3, 2, 1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
AssigneeID: int64Pointer(1),
|
AssigneeID: optional.Some(int64(1)),
|
||||||
},
|
},
|
||||||
[]int64{6, 1},
|
expectedIDs: []int64{6, 1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
MentionID: int64Pointer(4),
|
MentionID: optional.Some(int64(4)),
|
||||||
},
|
},
|
||||||
[]int64{1},
|
expectedIDs: []int64{1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
ReviewedID: int64Pointer(1),
|
ReviewedID: optional.Some(int64(1)),
|
||||||
},
|
},
|
||||||
[]int64{},
|
expectedIDs: []int64{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
ReviewRequestedID: int64Pointer(1),
|
ReviewRequestedID: optional.Some(int64(1)),
|
||||||
},
|
},
|
||||||
[]int64{12},
|
expectedIDs: []int64{12},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
SubscriberID: int64Pointer(1),
|
SubscriberID: optional.Some(int64(1)),
|
||||||
},
|
},
|
||||||
[]int64{11, 6, 5, 3, 2, 1},
|
expectedIDs: []int64{11, 6, 5, 3, 2, 1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// issue 20 request user 15 and team 5 which user 15 belongs to
|
// issue 20 request user 15 and team 5 which user 15 belongs to
|
||||||
// the review request number of issue 20 should be 1
|
// the review request number of issue 20 should be 1
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
ReviewRequestedID: int64Pointer(15),
|
ReviewRequestedID: optional.Some(int64(15)),
|
||||||
},
|
},
|
||||||
[]int64{12, 20},
|
expectedIDs: []int64{12, 20},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// user 20 approved the issue 20, so return nothing
|
// user 20 approved the issue 20, so return nothing
|
||||||
SearchOptions{
|
opts: SearchOptions{
|
||||||
ReviewRequestedID: int64Pointer(20),
|
ReviewRequestedID: optional.Some(int64(20)),
|
||||||
},
|
},
|
||||||
[]int64{},
|
expectedIDs: []int64{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,16 +315,13 @@ func searchIssueByLabelID(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchIssueByTime(t *testing.T) {
|
func searchIssueByTime(t *testing.T) {
|
||||||
int64Pointer := func(i int64) *int64 {
|
|
||||||
return &i
|
|
||||||
}
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
opts SearchOptions
|
opts SearchOptions
|
||||||
expectedIDs []int64
|
expectedIDs []int64
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
SearchOptions{
|
SearchOptions{
|
||||||
UpdatedAfterUnix: int64Pointer(0),
|
UpdatedAfterUnix: optional.Some(int64(0)),
|
||||||
},
|
},
|
||||||
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 1},
|
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 1},
|
||||||
},
|
},
|
||||||
|
@ -363,28 +357,25 @@ func searchIssueWithOrder(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchIssueInProject(t *testing.T) {
|
func searchIssueInProject(t *testing.T) {
|
||||||
int64Pointer := func(i int64) *int64 {
|
|
||||||
return &i
|
|
||||||
}
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
opts SearchOptions
|
opts SearchOptions
|
||||||
expectedIDs []int64
|
expectedIDs []int64
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
SearchOptions{
|
SearchOptions{
|
||||||
ProjectID: int64Pointer(1),
|
ProjectID: optional.Some(int64(1)),
|
||||||
},
|
},
|
||||||
[]int64{5, 3, 2, 1},
|
[]int64{5, 3, 2, 1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SearchOptions{
|
SearchOptions{
|
||||||
ProjectBoardID: int64Pointer(1),
|
ProjectBoardID: optional.Some(int64(1)),
|
||||||
},
|
},
|
||||||
[]int64{1},
|
[]int64{1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SearchOptions{
|
SearchOptions{
|
||||||
ProjectBoardID: int64Pointer(0), // issue with in default board
|
ProjectBoardID: optional.Some(int64(0)), // issue with in default board
|
||||||
},
|
},
|
||||||
[]int64{2},
|
[]int64{2},
|
||||||
},
|
},
|
||||||
|
|
|
@ -89,22 +89,22 @@ type SearchOptions struct {
|
||||||
|
|
||||||
MilestoneIDs []int64 // milestones the issues have
|
MilestoneIDs []int64 // milestones the issues have
|
||||||
|
|
||||||
ProjectID *int64 // project the issues belong to
|
ProjectID optional.Option[int64] // project the issues belong to
|
||||||
ProjectBoardID *int64 // project board the issues belong to
|
ProjectBoardID optional.Option[int64] // project board the issues belong to
|
||||||
|
|
||||||
PosterID *int64 // poster of the issues
|
PosterID optional.Option[int64] // poster of the issues
|
||||||
|
|
||||||
AssigneeID *int64 // assignee of the issues, zero means no assignee
|
AssigneeID optional.Option[int64] // assignee of the issues, zero means no assignee
|
||||||
|
|
||||||
MentionID *int64 // mentioned user of the issues
|
MentionID optional.Option[int64] // mentioned user of the issues
|
||||||
|
|
||||||
ReviewedID *int64 // reviewer of the issues
|
ReviewedID optional.Option[int64] // reviewer of the issues
|
||||||
ReviewRequestedID *int64 // requested reviewer of the issues
|
ReviewRequestedID optional.Option[int64] // requested reviewer of the issues
|
||||||
|
|
||||||
SubscriberID *int64 // subscriber of the issues
|
SubscriberID optional.Option[int64] // subscriber of the issues
|
||||||
|
|
||||||
UpdatedAfterUnix *int64
|
UpdatedAfterUnix optional.Option[int64]
|
||||||
UpdatedBeforeUnix *int64
|
UpdatedBeforeUnix optional.Option[int64]
|
||||||
|
|
||||||
db.Paginator
|
db.Paginator
|
||||||
|
|
||||||
|
|
|
@ -300,10 +300,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
ProjectID: func() *int64 {
|
ProjectID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -321,10 +318,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
ProjectID: func() *int64 {
|
ProjectID: optional.Some(int64(0)),
|
||||||
id := int64(0)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -342,10 +336,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
ProjectBoardID: func() *int64 {
|
ProjectBoardID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -363,10 +354,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
ProjectBoardID: func() *int64 {
|
ProjectBoardID: optional.Some(int64(0)),
|
||||||
id := int64(0)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -384,10 +372,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
PosterID: func() *int64 {
|
PosterID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -405,10 +390,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
AssigneeID: func() *int64 {
|
AssigneeID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -426,10 +408,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
AssigneeID: func() *int64 {
|
AssigneeID: optional.Some(int64(0)),
|
||||||
id := int64(0)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -447,10 +426,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
MentionID: func() *int64 {
|
MentionID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -468,10 +444,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
ReviewedID: func() *int64 {
|
ReviewedID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -489,10 +462,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
ReviewRequestedID: func() *int64 {
|
ReviewRequestedID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -510,10 +480,7 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
SubscriberID: func() *int64 {
|
SubscriberID: optional.Some(int64(1)),
|
||||||
id := int64(1)
|
|
||||||
return &id
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
@ -531,14 +498,8 @@ var cases = []*testIndexerCase{
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
PageSize: 5,
|
PageSize: 5,
|
||||||
},
|
},
|
||||||
UpdatedAfterUnix: func() *int64 {
|
UpdatedAfterUnix: optional.Some(int64(20)),
|
||||||
var t int64 = 20
|
UpdatedBeforeUnix: optional.Some(int64(30)),
|
||||||
return &t
|
|
||||||
}(),
|
|
||||||
UpdatedBeforeUnix: func() *int64 {
|
|
||||||
var t int64 = 30
|
|
||||||
return &t
|
|
||||||
}(),
|
|
||||||
},
|
},
|
||||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
assert.Equal(t, 5, len(result.Hits))
|
assert.Equal(t, 5, len(result.Hits))
|
||||||
|
|
|
@ -170,41 +170,41 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
||||||
query.And(inner_meilisearch.NewFilterIn("milestone_id", options.MilestoneIDs...))
|
query.And(inner_meilisearch.NewFilterIn("milestone_id", options.MilestoneIDs...))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ProjectID != nil {
|
if options.ProjectID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("project_id", *options.ProjectID))
|
query.And(inner_meilisearch.NewFilterEq("project_id", options.ProjectID.Value()))
|
||||||
}
|
}
|
||||||
if options.ProjectBoardID != nil {
|
if options.ProjectBoardID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("project_board_id", *options.ProjectBoardID))
|
query.And(inner_meilisearch.NewFilterEq("project_board_id", options.ProjectBoardID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.PosterID != nil {
|
if options.PosterID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("poster_id", *options.PosterID))
|
query.And(inner_meilisearch.NewFilterEq("poster_id", options.PosterID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.AssigneeID != nil {
|
if options.AssigneeID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("assignee_id", *options.AssigneeID))
|
query.And(inner_meilisearch.NewFilterEq("assignee_id", options.AssigneeID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.MentionID != nil {
|
if options.MentionID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("mention_ids", *options.MentionID))
|
query.And(inner_meilisearch.NewFilterEq("mention_ids", options.MentionID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ReviewedID != nil {
|
if options.ReviewedID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("reviewed_ids", *options.ReviewedID))
|
query.And(inner_meilisearch.NewFilterEq("reviewed_ids", options.ReviewedID.Value()))
|
||||||
}
|
}
|
||||||
if options.ReviewRequestedID != nil {
|
if options.ReviewRequestedID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("review_requested_ids", *options.ReviewRequestedID))
|
query.And(inner_meilisearch.NewFilterEq("review_requested_ids", options.ReviewRequestedID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.SubscriberID != nil {
|
if options.SubscriberID.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterEq("subscriber_ids", *options.SubscriberID))
|
query.And(inner_meilisearch.NewFilterEq("subscriber_ids", options.SubscriberID.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.UpdatedAfterUnix != nil {
|
if options.UpdatedAfterUnix.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterGte("updated_unix", *options.UpdatedAfterUnix))
|
query.And(inner_meilisearch.NewFilterGte("updated_unix", options.UpdatedAfterUnix.Value()))
|
||||||
}
|
}
|
||||||
if options.UpdatedBeforeUnix != nil {
|
if options.UpdatedBeforeUnix.Has() {
|
||||||
query.And(inner_meilisearch.NewFilterLte("updated_unix", *options.UpdatedBeforeUnix))
|
query.And(inner_meilisearch.NewFilterLte("updated_unix", options.UpdatedBeforeUnix.Value()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.SortBy == "" {
|
if options.SortBy == "" {
|
||||||
|
|
|
@ -269,28 +269,28 @@ func SearchIssues(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if since != 0 {
|
if since != 0 {
|
||||||
searchOpt.UpdatedAfterUnix = &since
|
searchOpt.UpdatedAfterUnix = optional.Some(since)
|
||||||
}
|
}
|
||||||
if before != 0 {
|
if before != 0 {
|
||||||
searchOpt.UpdatedBeforeUnix = &before
|
searchOpt.UpdatedBeforeUnix = optional.Some(before)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.IsSigned {
|
if ctx.IsSigned {
|
||||||
ctxUserID := ctx.Doer.ID
|
ctxUserID := ctx.Doer.ID
|
||||||
if ctx.FormBool("created") {
|
if ctx.FormBool("created") {
|
||||||
searchOpt.PosterID = &ctxUserID
|
searchOpt.PosterID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("assigned") {
|
if ctx.FormBool("assigned") {
|
||||||
searchOpt.AssigneeID = &ctxUserID
|
searchOpt.AssigneeID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("mentioned") {
|
if ctx.FormBool("mentioned") {
|
||||||
searchOpt.MentionID = &ctxUserID
|
searchOpt.MentionID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("review_requested") {
|
if ctx.FormBool("review_requested") {
|
||||||
searchOpt.ReviewRequestedID = &ctxUserID
|
searchOpt.ReviewRequestedID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("reviewed") {
|
if ctx.FormBool("reviewed") {
|
||||||
searchOpt.ReviewedID = &ctxUserID
|
searchOpt.ReviewedID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,10 +502,10 @@ func ListIssues(ctx *context.APIContext) {
|
||||||
SortBy: issue_indexer.SortByCreatedDesc,
|
SortBy: issue_indexer.SortByCreatedDesc,
|
||||||
}
|
}
|
||||||
if since != 0 {
|
if since != 0 {
|
||||||
searchOpt.UpdatedAfterUnix = &since
|
searchOpt.UpdatedAfterUnix = optional.Some(since)
|
||||||
}
|
}
|
||||||
if before != 0 {
|
if before != 0 {
|
||||||
searchOpt.UpdatedBeforeUnix = &before
|
searchOpt.UpdatedBeforeUnix = optional.Some(before)
|
||||||
}
|
}
|
||||||
if len(labelIDs) == 1 && labelIDs[0] == 0 {
|
if len(labelIDs) == 1 && labelIDs[0] == 0 {
|
||||||
searchOpt.NoLabelOnly = true
|
searchOpt.NoLabelOnly = true
|
||||||
|
@ -526,13 +526,13 @@ func ListIssues(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if createdByID > 0 {
|
if createdByID > 0 {
|
||||||
searchOpt.PosterID = &createdByID
|
searchOpt.PosterID = optional.Some(createdByID)
|
||||||
}
|
}
|
||||||
if assignedByID > 0 {
|
if assignedByID > 0 {
|
||||||
searchOpt.AssigneeID = &assignedByID
|
searchOpt.AssigneeID = optional.Some(assignedByID)
|
||||||
}
|
}
|
||||||
if mentionedByID > 0 {
|
if mentionedByID > 0 {
|
||||||
searchOpt.MentionID = &mentionedByID
|
searchOpt.MentionID = optional.Some(mentionedByID)
|
||||||
}
|
}
|
||||||
|
|
||||||
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
|
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
|
||||||
|
|
|
@ -2636,9 +2636,9 @@ func SearchIssues(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var projectID *int64
|
projectID := optional.None[int64]()
|
||||||
if v := ctx.FormInt64("project"); v > 0 {
|
if v := ctx.FormInt64("project"); v > 0 {
|
||||||
projectID = &v
|
projectID = optional.Some(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this api is also used in UI,
|
// this api is also used in UI,
|
||||||
|
@ -2667,28 +2667,28 @@ func SearchIssues(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if since != 0 {
|
if since != 0 {
|
||||||
searchOpt.UpdatedAfterUnix = &since
|
searchOpt.UpdatedAfterUnix = optional.Some(since)
|
||||||
}
|
}
|
||||||
if before != 0 {
|
if before != 0 {
|
||||||
searchOpt.UpdatedBeforeUnix = &before
|
searchOpt.UpdatedBeforeUnix = optional.Some(before)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.IsSigned {
|
if ctx.IsSigned {
|
||||||
ctxUserID := ctx.Doer.ID
|
ctxUserID := ctx.Doer.ID
|
||||||
if ctx.FormBool("created") {
|
if ctx.FormBool("created") {
|
||||||
searchOpt.PosterID = &ctxUserID
|
searchOpt.PosterID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("assigned") {
|
if ctx.FormBool("assigned") {
|
||||||
searchOpt.AssigneeID = &ctxUserID
|
searchOpt.AssigneeID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("mentioned") {
|
if ctx.FormBool("mentioned") {
|
||||||
searchOpt.MentionID = &ctxUserID
|
searchOpt.MentionID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("review_requested") {
|
if ctx.FormBool("review_requested") {
|
||||||
searchOpt.ReviewRequestedID = &ctxUserID
|
searchOpt.ReviewRequestedID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
if ctx.FormBool("reviewed") {
|
if ctx.FormBool("reviewed") {
|
||||||
searchOpt.ReviewedID = &ctxUserID
|
searchOpt.ReviewedID = optional.Some(ctxUserID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2795,9 +2795,9 @@ func ListIssues(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var projectID *int64
|
projectID := optional.None[int64]()
|
||||||
if v := ctx.FormInt64("project"); v > 0 {
|
if v := ctx.FormInt64("project"); v > 0 {
|
||||||
projectID = &v
|
projectID = optional.Some(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
isPull := optional.None[bool]()
|
isPull := optional.None[bool]()
|
||||||
|
@ -2835,10 +2835,10 @@ func ListIssues(ctx *context.Context) {
|
||||||
SortBy: issue_indexer.SortByCreatedDesc,
|
SortBy: issue_indexer.SortByCreatedDesc,
|
||||||
}
|
}
|
||||||
if since != 0 {
|
if since != 0 {
|
||||||
searchOpt.UpdatedAfterUnix = &since
|
searchOpt.UpdatedAfterUnix = optional.Some(since)
|
||||||
}
|
}
|
||||||
if before != 0 {
|
if before != 0 {
|
||||||
searchOpt.UpdatedBeforeUnix = &before
|
searchOpt.UpdatedBeforeUnix = optional.Some(before)
|
||||||
}
|
}
|
||||||
if len(labelIDs) == 1 && labelIDs[0] == 0 {
|
if len(labelIDs) == 1 && labelIDs[0] == 0 {
|
||||||
searchOpt.NoLabelOnly = true
|
searchOpt.NoLabelOnly = true
|
||||||
|
@ -2859,13 +2859,13 @@ func ListIssues(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if createdByID > 0 {
|
if createdByID > 0 {
|
||||||
searchOpt.PosterID = &createdByID
|
searchOpt.PosterID = optional.Some(createdByID)
|
||||||
}
|
}
|
||||||
if assignedByID > 0 {
|
if assignedByID > 0 {
|
||||||
searchOpt.AssigneeID = &assignedByID
|
searchOpt.AssigneeID = optional.Some(assignedByID)
|
||||||
}
|
}
|
||||||
if mentionedByID > 0 {
|
if mentionedByID > 0 {
|
||||||
searchOpt.MentionID = &mentionedByID
|
searchOpt.MentionID = optional.Some(mentionedByID)
|
||||||
}
|
}
|
||||||
|
|
||||||
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
|
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
|
||||||
|
|
|
@ -791,15 +791,15 @@ func getUserIssueStats(ctx *context.Context, ctxUser *user_model.User, filterMod
|
||||||
case issues_model.FilterModeYourRepositories:
|
case issues_model.FilterModeYourRepositories:
|
||||||
openClosedOpts.AllPublic = false
|
openClosedOpts.AllPublic = false
|
||||||
case issues_model.FilterModeAssign:
|
case issues_model.FilterModeAssign:
|
||||||
openClosedOpts.AssigneeID = &doerID
|
openClosedOpts.AssigneeID = optional.Some(doerID)
|
||||||
case issues_model.FilterModeCreate:
|
case issues_model.FilterModeCreate:
|
||||||
openClosedOpts.PosterID = &doerID
|
openClosedOpts.PosterID = optional.Some(doerID)
|
||||||
case issues_model.FilterModeMention:
|
case issues_model.FilterModeMention:
|
||||||
openClosedOpts.MentionID = &doerID
|
openClosedOpts.MentionID = optional.Some(doerID)
|
||||||
case issues_model.FilterModeReviewRequested:
|
case issues_model.FilterModeReviewRequested:
|
||||||
openClosedOpts.ReviewRequestedID = &doerID
|
openClosedOpts.ReviewRequestedID = optional.Some(doerID)
|
||||||
case issues_model.FilterModeReviewed:
|
case issues_model.FilterModeReviewed:
|
||||||
openClosedOpts.ReviewedID = &doerID
|
openClosedOpts.ReviewedID = optional.Some(doerID)
|
||||||
}
|
}
|
||||||
openClosedOpts.IsClosed = optional.Some(false)
|
openClosedOpts.IsClosed = optional.Some(false)
|
||||||
ret.OpenCount, err = issue_indexer.CountIssues(ctx, openClosedOpts)
|
ret.OpenCount, err = issue_indexer.CountIssues(ctx, openClosedOpts)
|
||||||
|
@ -817,23 +817,23 @@ func getUserIssueStats(ctx *context.Context, ctxUser *user_model.User, filterMod
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ret.AssignCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.AssigneeID = &doerID }))
|
ret.AssignCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.AssigneeID = optional.Some(doerID) }))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ret.CreateCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.PosterID = &doerID }))
|
ret.CreateCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.PosterID = optional.Some(doerID) }))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ret.MentionCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.MentionID = &doerID }))
|
ret.MentionCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.MentionID = optional.Some(doerID) }))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ret.ReviewRequestedCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.ReviewRequestedID = &doerID }))
|
ret.ReviewRequestedCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.ReviewRequestedID = optional.Some(doerID) }))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ret.ReviewedCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.ReviewedID = &doerID }))
|
ret.ReviewedCount, err = issue_indexer.CountIssues(ctx, opts.Copy(func(o *issue_indexer.SearchOptions) { o.ReviewedID = optional.Some(doerID) }))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue