@@ -1251,6 +1251,8 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) {
1251
1251
1252
1252
if opts .AssigneeID > 0 {
1253
1253
applyAssigneeCondition (sess , opts .AssigneeID )
1254
+ } else if opts .AssigneeID == db .NoConditionID {
1255
+ sess .Where ("issue.id NOT IN (SELECT issue_id FROM issue_assignees)" )
1254
1256
}
1255
1257
1256
1258
if opts .PosterID > 0 {
@@ -1312,13 +1314,17 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) {
1312
1314
sess .And (builder.Eq {"repository.is_archived" : opts .IsArchived .IsTrue ()})
1313
1315
}
1314
1316
1315
- if opts .LabelIDs != nil {
1316
- for i , labelID := range opts .LabelIDs {
1317
- if labelID > 0 {
1318
- sess .Join ("INNER" , fmt .Sprintf ("issue_label il%d" , i ),
1319
- fmt .Sprintf ("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d" , i , labelID ))
1320
- } else {
1321
- sess .Where ("issue.id not in (select issue_id from issue_label where label_id = ?)" , - labelID )
1317
+ if len (opts .LabelIDs ) > 0 {
1318
+ if opts .LabelIDs [0 ] == 0 {
1319
+ sess .Where ("issue.id NOT IN (SELECT issue_id FROM issue_label)" )
1320
+ } else {
1321
+ for i , labelID := range opts .LabelIDs {
1322
+ if labelID > 0 {
1323
+ sess .Join ("INNER" , fmt .Sprintf ("issue_label il%d" , i ),
1324
+ fmt .Sprintf ("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d" , i , labelID ))
1325
+ } else if labelID < 0 { // 0 is not supported here, so just ignore it
1326
+ sess .Where ("issue.id not in (select issue_id from issue_label where label_id = ?)" , - labelID )
1327
+ }
1322
1328
}
1323
1329
}
1324
1330
}
@@ -1705,17 +1711,21 @@ func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats,
1705
1711
sess .In ("issue.id" , issueIDs )
1706
1712
}
1707
1713
1708
- if len (opts .Labels ) > 0 && opts . Labels != "0" {
1714
+ if len (opts .Labels ) > 0 {
1709
1715
labelIDs , err := base .StringsToInt64s (strings .Split (opts .Labels , "," ))
1710
1716
if err != nil {
1711
1717
log .Warn ("Malformed Labels argument: %s" , opts .Labels )
1712
1718
} else {
1713
- for i , labelID := range labelIDs {
1714
- if labelID > 0 {
1715
- sess .Join ("INNER" , fmt .Sprintf ("issue_label il%d" , i ),
1716
- fmt .Sprintf ("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d" , i , labelID ))
1717
- } else {
1718
- sess .Where ("issue.id NOT IN (SELECT issue_id FROM issue_label WHERE label_id = ?)" , - labelID )
1719
+ if labelIDs [0 ] == 0 {
1720
+ sess .Where ("issue.id NOT IN (SELECT issue_id FROM issue_label)" )
1721
+ } else {
1722
+ for i , labelID := range labelIDs {
1723
+ if labelID > 0 {
1724
+ sess .Join ("INNER" , fmt .Sprintf ("issue_label il%d" , i ),
1725
+ fmt .Sprintf ("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d" , i , labelID ))
1726
+ } else if labelID < 0 { // 0 is not supported here, so just ignore it
1727
+ sess .Where ("issue.id NOT IN (SELECT issue_id FROM issue_label WHERE label_id = ?)" , - labelID )
1728
+ }
1719
1729
}
1720
1730
}
1721
1731
}
@@ -1734,6 +1744,8 @@ func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats,
1734
1744
1735
1745
if opts .AssigneeID > 0 {
1736
1746
applyAssigneeCondition (sess , opts .AssigneeID )
1747
+ } else if opts .AssigneeID == db .NoConditionID {
1748
+ sess .Where ("id NOT IN (SELECT issue_id FROM issue_assignees)" )
1737
1749
}
1738
1750
1739
1751
if opts .PosterID > 0 {
0 commit comments