Explain SearchOptions and fix ToSearchOptions (#26542)
Follow #26012 #26490. A detailed description has been added to the comment.
This commit is contained in:
parent
1432d4eab9
commit
3b129aaa80
3 changed files with 35 additions and 22 deletions
|
@ -17,10 +17,6 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
|
|||
IsClosed: opts.IsClosed,
|
||||
}
|
||||
|
||||
if opts.ProjectID != 0 {
|
||||
searchOpt.ProjectID = &opts.ProjectID
|
||||
}
|
||||
|
||||
if len(opts.LabelIDs) == 1 && opts.LabelIDs[0] == 0 {
|
||||
searchOpt.NoLabelOnly = true
|
||||
} else {
|
||||
|
@ -41,25 +37,27 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
|
|||
searchOpt.MilestoneIDs = opts.MilestoneIDs
|
||||
}
|
||||
|
||||
if opts.AssigneeID > 0 {
|
||||
searchOpt.AssigneeID = &opts.AssigneeID
|
||||
}
|
||||
if opts.PosterID > 0 {
|
||||
searchOpt.PosterID = &opts.PosterID
|
||||
}
|
||||
if opts.MentionedID > 0 {
|
||||
searchOpt.MentionID = &opts.MentionedID
|
||||
}
|
||||
if opts.ReviewedID > 0 {
|
||||
searchOpt.ReviewedID = &opts.ReviewedID
|
||||
}
|
||||
if opts.ReviewRequestedID > 0 {
|
||||
searchOpt.ReviewRequestedID = &opts.ReviewRequestedID
|
||||
}
|
||||
if opts.SubscriberID > 0 {
|
||||
searchOpt.SubscriberID = &opts.SubscriberID
|
||||
// See the comment of issues_model.SearchOptions for the reason why we need to convert
|
||||
convertID := func(id int64) *int64 {
|
||||
if id > 0 {
|
||||
return &id
|
||||
}
|
||||
if id == db.NoConditionID {
|
||||
var zero int64
|
||||
return &zero
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
searchOpt.ProjectID = convertID(opts.ProjectID)
|
||||
searchOpt.ProjectBoardID = convertID(opts.ProjectBoardID)
|
||||
searchOpt.PosterID = convertID(opts.PosterID)
|
||||
searchOpt.AssigneeID = convertID(opts.AssigneeID)
|
||||
searchOpt.MentionID = convertID(opts.MentionedID)
|
||||
searchOpt.ReviewedID = convertID(opts.ReviewedID)
|
||||
searchOpt.ReviewRequestedID = convertID(opts.ReviewRequestedID)
|
||||
searchOpt.SubscriberID = convertID(opts.SubscriberID)
|
||||
|
||||
if opts.UpdatedAfterUnix > 0 {
|
||||
searchOpt.UpdatedAfterUnix = &opts.UpdatedAfterUnix
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue