1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

User specific repoID or xorm builder conditions for issue search (#19475) (#19476)

This commit is contained in:
6543
2022-04-25 15:28:47 +02:00
committed by GitHub
parent a6b32adc45
commit 8d7f1e430a
8 changed files with 22 additions and 32 deletions

View File

@@ -1165,7 +1165,8 @@ func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error) {
// IssuesOptions represents options of an issue.
type IssuesOptions struct {
db.ListOptions
RepoIDs []int64 // include all repos if empty
RepoID int64 // overwrites RepoCond if not 0
RepoCond builder.Cond
AssigneeID int64
PosterID int64
MentionedID int64
@@ -1256,15 +1257,15 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) {
sess.In("issue.id", opts.IssueIDs)
}
if len(opts.RepoIDs) > 0 {
applyReposCondition(sess, opts.RepoIDs)
if opts.RepoID != 0 {
opts.RepoCond = builder.Eq{"issue.repo_id": opts.RepoID}
}
if opts.RepoCond != nil {
sess.And(opts.RepoCond)
}
switch opts.IsClosed {
case util.OptionalBoolTrue:
sess.And("issue.is_closed=?", true)
case util.OptionalBoolFalse:
sess.And("issue.is_closed=?", false)
if !opts.IsClosed.IsNone() {
sess.And("issue.is_closed=?", opts.IsClosed.IsTrue())
}
if opts.AssigneeID > 0 {
@@ -1383,10 +1384,6 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, org *Organizati
return cond
}
func applyReposCondition(sess *xorm.Session, repoIDs []int64) *xorm.Session {
return sess.In("issue.repo_id", repoIDs)
}
func applyAssigneeCondition(sess *xorm.Session, assigneeID int64) *xorm.Session {
return sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
And("issue_assignees.assignee_id = ?", assigneeID)