-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add no labels and no milestones and no assignees filters #20047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 27 commits
7b651c8
41e9045
7137988
468d7b5
ad8ad91
8dcaa83
e113012
5f4e96b
ed16f95
77fb81c
fc4972a
375f3bf
3d05644
41718e0
ba3b5c3
7f045e0
a9407dc
012526a
8e614fb
e9dbdd7
923888e
07637a9
df8c1d0
bc9b0f1
96ecf1e
014cd82
5c05e53
176b24d
c8436d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1288,7 +1288,7 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) { | |
sess.And("issue.is_closed=?", opts.IsClosed.IsTrue()) | ||
} | ||
|
||
if opts.AssigneeID > 0 { | ||
if opts.AssigneeID != 0 { | ||
applyAssigneeCondition(sess, opts.AssigneeID) | ||
} | ||
|
||
|
@@ -1309,7 +1309,11 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) { | |
} | ||
|
||
if len(opts.MilestoneIDs) > 0 { | ||
sess.In("issue.milestone_id", opts.MilestoneIDs) | ||
if opts.MilestoneIDs[0] > 0 { | ||
sess.In("issue.milestone_id", opts.MilestoneIDs) | ||
} else if opts.MilestoneIDs[0] == -1 { | ||
sess.And("issue.milestone_id = 0") | ||
} | ||
} | ||
|
||
if opts.UpdatedAfterUnix != 0 { | ||
|
@@ -1344,14 +1348,23 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) { | |
} | ||
|
||
if opts.LabelIDs != nil { | ||
var noLabelsIDs []int64 | ||
hasNoLabel := false | ||
for i, labelID := range opts.LabelIDs { | ||
if labelID > 0 { | ||
sess.Join("INNER", fmt.Sprintf("issue_label il%d", i), | ||
fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID)) | ||
} else { | ||
sess.Where("issue.id not in (select issue_id from issue_label where label_id = ?)", -labelID) | ||
} else if labelID < 0 { | ||
noLabelsIDs = append(noLabelsIDs, -labelID) | ||
hasNoLabel = true | ||
} | ||
} | ||
if hasNoLabel { | ||
sess.NotIn("issue.id", | ||
tyroneyeh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
builder.Select("issue_id"). | ||
From("issue_label"). | ||
Where(builder.In("label_id", noLabelsIDs))) | ||
} | ||
} | ||
|
||
if len(opts.IncludedLabelNames) > 0 { | ||
|
@@ -1449,6 +1462,11 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, org *organizati | |
} | ||
|
||
func applyAssigneeCondition(sess *xorm.Session, assigneeID int64) *xorm.Session { | ||
if assigneeID == -1 { | ||
return sess.Join("LEFT", "issue_assignees", "issue.id = issue_assignees.issue_id"). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you provide an example - never saw an example of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I have done that in the previous comment. |
||
And(builder.IsNull{"issue_assignees.issue_id"}) | ||
} | ||
|
||
return sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id"). | ||
And("issue_assignees.assignee_id = ?", assigneeID) | ||
} | ||
|
@@ -1702,27 +1720,36 @@ func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats, | |
sess.In("issue.id", issueIDs) | ||
} | ||
|
||
if len(opts.Labels) > 0 && opts.Labels != "0" { | ||
if len(opts.Labels) > 0 { | ||
labelIDs, err := base.StringsToInt64s(strings.Split(opts.Labels, ",")) | ||
if err != nil { | ||
log.Warn("Malformed Labels argument: %s", opts.Labels) | ||
} else { | ||
var noLabelsIDs []int64 | ||
hasNoLabel := false | ||
for i, labelID := range labelIDs { | ||
if labelID > 0 { | ||
sess.Join("INNER", fmt.Sprintf("issue_label il%d", i), | ||
fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID)) | ||
} else { | ||
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_label WHERE label_id = ?)", -labelID) | ||
} else if labelID < 0 { | ||
// sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_label WHERE label_id = ?)", -labelID) | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
noLabelsIDs = append(noLabelsIDs, -labelID) | ||
hasNoLabel = true | ||
} | ||
} | ||
if hasNoLabel { | ||
sess.NotIn("issue.id", builder.Select("issue_id").From("issue_label").Where(builder.In("label_id", noLabelsIDs))) | ||
} | ||
} | ||
} | ||
|
||
if opts.MilestoneID > 0 { | ||
sess.And("issue.milestone_id = ?", opts.MilestoneID) | ||
} else if opts.MilestoneID == -1 { | ||
sess.And("issue.milestone_id = 0") | ||
} | ||
|
||
if opts.AssigneeID > 0 { | ||
if opts.AssigneeID != 0 { | ||
applyAssigneeCondition(sess, opts.AssigneeID) | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are excluded Labels, not no Label. So you still missed real No Label issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is done by set all lables who you dould select as exclude ...
... so it works
the question is if se should use a keyword instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are hundreds labels in this repository, it's difficult to select labels from the UI?