@@ -155,6 +155,18 @@ func applyMilestoneCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.Sess
155
155
return sess
156
156
}
157
157
158
+ func applyProjectCondition (sess * xorm.Session , opts * IssuesOptions ) * xorm.Session {
159
+ if opts .ProjectID > 0 { // specific project
160
+ sess .Join ("INNER" , "project_issue" , "issue.id = project_issue.issue_id" ).
161
+ And ("project_issue.project_id=?" , opts .ProjectID )
162
+ } else if opts .ProjectID == db .NoConditionID { // show those that are in no project
163
+ sess .And (builder .NotIn ("issue.id" , builder .Select ("issue_id" ).From ("project_issue" ).And (builder.Neq {"project_id" : 0 })))
164
+ }
165
+ // opts.ProjectID == 0 means all projects,
166
+ // do not need to apply any condition
167
+ return sess
168
+ }
169
+
158
170
func applyRepoConditions (sess * xorm.Session , opts * IssuesOptions ) * xorm.Session {
159
171
if len (opts .RepoIDs ) == 1 {
160
172
opts .RepoCond = builder.Eq {"issue.repo_id" : opts .RepoIDs [0 ]}
@@ -213,12 +225,7 @@ func applyConditions(sess *xorm.Session, opts *IssuesOptions) *xorm.Session {
213
225
sess .And (builder.Lte {"issue.updated_unix" : opts .UpdatedBeforeUnix })
214
226
}
215
227
216
- if opts .ProjectID > 0 {
217
- sess .Join ("INNER" , "project_issue" , "issue.id = project_issue.issue_id" ).
218
- And ("project_issue.project_id=?" , opts .ProjectID )
219
- } else if opts .ProjectID == db .NoConditionID { // show those that are in no project
220
- sess .And (builder .NotIn ("issue.id" , builder .Select ("issue_id" ).From ("project_issue" )))
221
- }
228
+ applyProjectCondition (sess , opts )
222
229
223
230
if opts .ProjectBoardID != 0 {
224
231
if opts .ProjectBoardID > 0 {
0 commit comments