diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-04-30 21:12:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-30 09:12:49 -0400 |
commit | 3f0651d4d61d62a16e1bb672056014ab02db5746 (patch) | |
tree | 035e1fd9edf7383b0abad6e89c2db4cd2b8a2355 /models | |
parent | e3750370df3be1413b1526668cbee60dc2a39f03 (diff) | |
download | gitea-3f0651d4d61d62a16e1bb672056014ab02db5746.tar.gz gitea-3f0651d4d61d62a16e1bb672056014ab02db5746.zip |
Improve milestone filter on issues page (#22423)
Now we have `All milestones`, `No milestones`, `Open milestones` and
`Closed milestones`.
Fix #11924
Fix #22411
<img width="1166" alt="image"
src="https://user-images.githubusercontent.com/81045/212243375-95eea035-a972-44b8-8088-53db614cb07e.png">
Diffstat (limited to 'models')
-rw-r--r-- | models/db/search.go | 2 | ||||
-rw-r--r-- | models/issues/issue.go | 8 |
2 files changed, 7 insertions, 3 deletions
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 { |