@@ -27,8 +27,8 @@ type IssuesOptions struct { //nolint
2727 RepoIDs []int64 // overwrites RepoCond if the length is not 0
2828 AllPublic bool // include also all public repositories
2929 RepoCond builder.Cond
30- AssigneeID optional. Option [ int64 ]
31- PosterID optional. Option [ int64 ]
30+ AssigneeID string // "(none)" or "(any)" or a user ID
31+ PosterID string // "(none)" or "(any)" or a user ID
3232 MentionedID int64
3333 ReviewRequestedID int64
3434 ReviewedID int64
@@ -356,26 +356,25 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, owner *user_mod
356356 return cond
357357}
358358
359- func applyAssigneeCondition (sess * xorm.Session , assigneeID optional. Option [ int64 ] ) {
359+ func applyAssigneeCondition (sess * xorm.Session , assigneeID string ) {
360360 // old logic: 0 is also treated as "not filtering assignee", because the "assignee" was read as FormInt64
361- if ! assigneeID .Has () || assigneeID .Value () == 0 {
362- return
363- }
364- if assigneeID .Value () == db .NoConditionID {
361+ if assigneeID == "(none)" {
365362 sess .Where ("issue.id NOT IN (SELECT issue_id FROM issue_assignees)" )
366- } else {
363+ } else if assigneeID == "(any)" {
364+ sess .Where ("issue.id IN (SELECT issue_id FROM issue_assignees)" )
365+ } else if assigneeIDInt64 , _ := strconv .ParseInt (assigneeID , 10 , 64 ); assigneeIDInt64 > 0 {
367366 sess .Join ("INNER" , "issue_assignees" , "issue.id = issue_assignees.issue_id" ).
368- And ("issue_assignees.assignee_id = ?" , assigneeID . Value () )
367+ And ("issue_assignees.assignee_id = ?" , assigneeIDInt64 )
369368 }
370369}
371370
372- func applyPosterCondition (sess * xorm.Session , posterID optional. Option [ int64 ] ) {
373- if ! posterID . Has () {
374- return
375- }
376- // poster doesn't need to support db.NoConditionID(-1), so just use the value as-is
377- if posterID . Has () {
378- sess .And ("issue.poster_id=?" , posterID . Value () )
371+ func applyPosterCondition (sess * xorm.Session , posterID string ) {
372+ // Actually every issue has a poster.
373+ // The "(none)" is for internal usage only: when doer tries to search non-existing user as poster, use "(none)" to return empty result.
374+ if posterID == "(none)" {
375+ sess . And ( "issue.poster_id=0" )
376+ } else if posterIDInt64 , _ := strconv . ParseInt ( posterID , 10 , 64 ); posterIDInt64 > 0 {
377+ sess .And ("issue.poster_id=?" , posterIDInt64 )
379378 }
380379}
381380
0 commit comments