return sess
}
+func applyProjectCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.Session {
+ if opts.ProjectID > 0 { // specific project
+ sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
+ And("project_issue.project_id=?", opts.ProjectID)
+ } else if opts.ProjectID == db.NoConditionID { // show those that are in no project
+ sess.And(builder.NotIn("issue.id", builder.Select("issue_id").From("project_issue").And(builder.Neq{"project_id": 0})))
+ }
+ // opts.ProjectID == 0 means all projects,
+ // do not need to apply any condition
+ return sess
+}
+
func applyRepoConditions(sess *xorm.Session, opts *IssuesOptions) *xorm.Session {
if len(opts.RepoIDs) == 1 {
opts.RepoCond = builder.Eq{"issue.repo_id": opts.RepoIDs[0]}
sess.And(builder.Lte{"issue.updated_unix": opts.UpdatedBeforeUnix})
}
- if opts.ProjectID > 0 {
- sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
- And("project_issue.project_id=?", opts.ProjectID)
- } else if opts.ProjectID == db.NoConditionID { // show those that are in no project
- sess.And(builder.NotIn("issue.id", builder.Select("issue_id").From("project_issue")))
- }
+ applyProjectCondition(sess, opts)
if opts.ProjectBoardID != 0 {
if opts.ProjectBoardID > 0 {
applyMilestoneCondition(sess, opts)
- if opts.ProjectID > 0 {
- sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
- And("project_issue.project_id=?", opts.ProjectID)
- }
+ applyProjectCondition(sess, opts)
if opts.AssigneeID > 0 {
applyAssigneeCondition(sess, opts.AssigneeID)