@@ -168,6 +168,18 @@ func applyMilestoneCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.Sess
168
168
return sess
169
169
}
170
170
171
+ func applyProjectCondition (sess * xorm.Session , opts * IssuesOptions ) * xorm.Session {
172
+ if opts .ProjectID > 0 { // specific project
173
+ sess .Join ("INNER" , "project_issue" , "issue.id = project_issue.issue_id" ).
174
+ And ("project_issue.project_id=?" , opts .ProjectID )
175
+ } else if opts .ProjectID == db .NoConditionID { // show those that are in no project
176
+ sess .And (builder .NotIn ("issue.id" , builder .Select ("issue_id" ).From ("project_issue" ).And (builder.Neq {"project_id" : 0 })))
177
+ }
178
+ // opts.ProjectID == 0 means all projects,
179
+ // do not need to apply any condition
180
+ return sess
181
+ }
182
+
171
183
func applyRepoConditions (sess * xorm.Session , opts * IssuesOptions ) * xorm.Session {
172
184
if len (opts .RepoIDs ) == 1 {
173
185
opts .RepoCond = builder.Eq {"issue.repo_id" : opts .RepoIDs [0 ]}
@@ -226,12 +238,7 @@ func applyConditions(sess *xorm.Session, opts *IssuesOptions) *xorm.Session {
226
238
sess .And (builder.Lte {"issue.updated_unix" : opts .UpdatedBeforeUnix })
227
239
}
228
240
229
- if opts .ProjectID > 0 {
230
- sess .Join ("INNER" , "project_issue" , "issue.id = project_issue.issue_id" ).
231
- And ("project_issue.project_id=?" , opts .ProjectID )
232
- } else if opts .ProjectID == db .NoConditionID { // show those that are in no project
233
- sess .And (builder .NotIn ("issue.id" , builder .Select ("issue_id" ).From ("project_issue" )))
234
- }
241
+ applyProjectCondition (sess , opts )
235
242
236
243
if opts .ProjectBoardID != 0 {
237
244
if opts .ProjectBoardID > 0 {
0 commit comments