From 3f0651d4d61d62a16e1bb672056014ab02db5746 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 30 Apr 2023 21:12:49 +0800 Subject: Improve milestone filter on issues page (#22423) Now we have `All milestones`, `No milestones`, `Open milestones` and `Closed milestones`. Fix #11924 Fix #22411 image --- models/db/search.go | 2 +- models/issues/issue.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'models') diff --git a/models/db/search.go b/models/db/search.go index 26e082756a..105cb64c41 100644 --- a/models/db/search.go +++ b/models/db/search.go @@ -31,5 +31,5 @@ const ( const ( // Which means a condition to filter the records which don't match any id. // It's different from zero which means the condition could be ignored. - NoneID = -1 + NoConditionID = -1 ) diff --git a/models/issues/issue.go b/models/issues/issue.go index 4f8e9e161d..8c173433f2 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -1273,7 +1273,9 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) { applySubscribedCondition(sess, opts.SubscriberID) } - if len(opts.MilestoneIDs) > 0 { + if len(opts.MilestoneIDs) == 1 && opts.MilestoneIDs[0] == db.NoConditionID { + sess.And("issue.milestone_id = 0") + } else if len(opts.MilestoneIDs) > 0 { sess.In("issue.milestone_id", opts.MilestoneIDs) } @@ -1287,7 +1289,7 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) { 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.NoneID { // show those that are in no project + } 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"))) } @@ -1721,6 +1723,8 @@ func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats, if opts.MilestoneID > 0 { sess.And("issue.milestone_id = ?", opts.MilestoneID) + } else if opts.MilestoneID == db.NoConditionID { + sess.And("issue.milestone_id = 0") } if opts.ProjectID > 0 { -- cgit v1.2.3