aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-12-11 14:33:24 +0800
committerGitHub <noreply@github.com>2024-12-11 06:33:24 +0000
commite619384098419569e570796a57ee6af4948067ae (patch)
tree9c5413be580d91ed9912878f80336eab89543670 /modules
parent734ddf71180a9bf843d12dd9664eed28ba1a5748 (diff)
downloadgitea-e619384098419569e570796a57ee6af4948067ae.tar.gz
gitea-e619384098419569e570796a57ee6af4948067ae.zip
Add label/author/assignee filters to the user/org home issue list (#32779)
Replace #26661, fix #25979 Not perfect, but usable and much better than before. Since it is quite complex, I am not quite sure whether there would be any regression, if any, I will fix in first time. I have tested the related pages many times: issue list, milestone issue list, project view, user issue list, org issue list.
Diffstat (limited to 'modules')
-rw-r--r--modules/indexer/issues/db/options.go4
-rw-r--r--modules/indexer/issues/dboptions.go12
-rw-r--r--modules/indexer/issues/indexer_test.go2
3 files changed, 9 insertions, 9 deletions
diff --git a/modules/indexer/issues/db/options.go b/modules/indexer/issues/db/options.go
index 875a4ca279..98b097f871 100644
--- a/modules/indexer/issues/db/options.go
+++ b/modules/indexer/issues/db/options.go
@@ -54,8 +54,8 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
RepoIDs: options.RepoIDs,
AllPublic: options.AllPublic,
RepoCond: nil,
- AssigneeID: convertID(options.AssigneeID),
- PosterID: convertID(options.PosterID),
+ AssigneeID: optional.Some(convertID(options.AssigneeID)),
+ PosterID: options.PosterID,
MentionedID: convertID(options.MentionID),
ReviewRequestedID: convertID(options.ReviewRequestedID),
ReviewedID: convertID(options.ReviewedID),
diff --git a/modules/indexer/issues/dboptions.go b/modules/indexer/issues/dboptions.go
index c1f454eeee..1a0f241e61 100644
--- a/modules/indexer/issues/dboptions.go
+++ b/modules/indexer/issues/dboptions.go
@@ -40,14 +40,14 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
if opts.ProjectID > 0 {
searchOpt.ProjectID = optional.Some(opts.ProjectID)
- } else if opts.ProjectID == -1 { // FIXME: this is inconsistent from other places
+ } else if opts.ProjectID == db.NoConditionID { // FIXME: this is inconsistent from other places
searchOpt.ProjectID = optional.Some[int64](0) // Those issues with no project(projectid==0)
}
- if opts.AssigneeID > 0 {
- searchOpt.AssigneeID = optional.Some(opts.AssigneeID)
- } else if opts.AssigneeID == -1 { // FIXME: this is inconsistent from other places
- searchOpt.AssigneeID = optional.Some[int64](0)
+ if opts.AssigneeID.Value() == db.NoConditionID {
+ searchOpt.AssigneeID = optional.Some[int64](0) // FIXME: this is inconsistent from other places, 0 means "no assignee"
+ } else if opts.AssigneeID.Value() != 0 {
+ searchOpt.AssigneeID = opts.AssigneeID
}
// See the comment of issues_model.SearchOptions for the reason why we need to convert
@@ -62,7 +62,7 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
}
searchOpt.ProjectColumnID = convertID(opts.ProjectColumnID)
- searchOpt.PosterID = convertID(opts.PosterID)
+ searchOpt.PosterID = opts.PosterID
searchOpt.MentionID = convertID(opts.MentionedID)
searchOpt.ReviewedID = convertID(opts.ReviewedID)
searchOpt.ReviewRequestedID = convertID(opts.ReviewRequestedID)
diff --git a/modules/indexer/issues/indexer_test.go b/modules/indexer/issues/indexer_test.go
index 0dce654181..7c3ba75bb0 100644
--- a/modules/indexer/issues/indexer_test.go
+++ b/modules/indexer/issues/indexer_test.go
@@ -191,7 +191,7 @@ func searchIssueByID(t *testing.T) {
},
{
// NOTE: This tests no assignees filtering and also ToSearchOptions() to ensure it will set AssigneeID to 0 when it is passed as -1.
- opts: *ToSearchOptions("", &issues.IssuesOptions{AssigneeID: -1}),
+ opts: *ToSearchOptions("", &issues.IssuesOptions{AssigneeID: optional.Some(db.NoConditionID)}),
expectedIDs: []int64{22, 21, 16, 15, 14, 13, 12, 11, 20, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2},
},
{