mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	Allow filtering issues by any assignee (#33343)
This is the opposite of the "No assignee" filter, it will match all issues that have at least one assignee. Before  After  --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -27,8 +27,8 @@ type IssuesOptions struct { //nolint | ||||
| 	RepoIDs            []int64 // overwrites RepoCond if the length is not 0 | ||||
| 	AllPublic          bool    // include also all public repositories | ||||
| 	RepoCond           builder.Cond | ||||
| 	AssigneeID         optional.Option[int64] | ||||
| 	PosterID           optional.Option[int64] | ||||
| 	AssigneeID         string // "(none)" or "(any)" or a user ID | ||||
| 	PosterID           string // "(none)" or "(any)" or a user ID | ||||
| 	MentionedID        int64 | ||||
| 	ReviewRequestedID  int64 | ||||
| 	ReviewedID         int64 | ||||
| @@ -356,26 +356,25 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, owner *user_mod | ||||
| 	return cond | ||||
| } | ||||
|  | ||||
| func applyAssigneeCondition(sess *xorm.Session, assigneeID optional.Option[int64]) { | ||||
| func applyAssigneeCondition(sess *xorm.Session, assigneeID string) { | ||||
| 	// old logic: 0 is also treated as "not filtering assignee", because the "assignee" was read as FormInt64 | ||||
| 	if !assigneeID.Has() || assigneeID.Value() == 0 { | ||||
| 		return | ||||
| 	} | ||||
| 	if assigneeID.Value() == db.NoConditionID { | ||||
| 	if assigneeID == "(none)" { | ||||
| 		sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)") | ||||
| 	} else { | ||||
| 	} else if assigneeID == "(any)" { | ||||
| 		sess.Where("issue.id IN (SELECT issue_id FROM issue_assignees)") | ||||
| 	} else if assigneeIDInt64, _ := strconv.ParseInt(assigneeID, 10, 64); assigneeIDInt64 > 0 { | ||||
| 		sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id"). | ||||
| 			And("issue_assignees.assignee_id = ?", assigneeID.Value()) | ||||
| 			And("issue_assignees.assignee_id = ?", assigneeIDInt64) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func applyPosterCondition(sess *xorm.Session, posterID optional.Option[int64]) { | ||||
| 	if !posterID.Has() { | ||||
| 		return | ||||
| 	} | ||||
| 	// poster doesn't need to support db.NoConditionID(-1), so just use the value as-is | ||||
| 	if posterID.Has() { | ||||
| 		sess.And("issue.poster_id=?", posterID.Value()) | ||||
| func applyPosterCondition(sess *xorm.Session, posterID string) { | ||||
| 	// Actually every issue has a poster. | ||||
| 	// The "(none)" is for internal usage only: when doer tries to search non-existing user as poster, use "(none)" to return empty result. | ||||
| 	if posterID == "(none)" { | ||||
| 		sess.And("issue.poster_id=0") | ||||
| 	} else if posterIDInt64, _ := strconv.ParseInt(posterID, 10, 64); posterIDInt64 > 0 { | ||||
| 		sess.And("issue.poster_id=?", posterIDInt64) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user