mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 18:54:39 +02:00
Improject filter search method
This commit is contained in:
parent
1f43f8a566
commit
4f2532de42
@ -16,6 +16,7 @@ import (
|
|||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/container"
|
"code.gitea.io/gitea/modules/container"
|
||||||
"code.gitea.io/gitea/modules/optional"
|
"code.gitea.io/gitea/modules/optional"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
@ -196,17 +197,10 @@ func applyMilestoneCondition(sess *xorm.Session, opts *IssuesOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applyProjectCondition(sess *xorm.Session, opts *IssuesOptions) {
|
func applyProjectCondition(sess *xorm.Session, opts *IssuesOptions) {
|
||||||
|
opts.ProjectIDs = util.RemoveValue(opts.ProjectIDs, 0)
|
||||||
if len(opts.ProjectIDs) > 0 { // specific project
|
if len(opts.ProjectIDs) > 0 { // specific project
|
||||||
var includedProjectIDs []int64
|
|
||||||
for _, projectID := range opts.ProjectIDs {
|
|
||||||
if projectID > 0 {
|
|
||||||
includedProjectIDs = append(includedProjectIDs, projectID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(includedProjectIDs) > 0 {
|
|
||||||
sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
|
sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
|
||||||
In("project_issue.project_id", includedProjectIDs)
|
In("project_issue.project_id", opts.ProjectIDs)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// opts.ProjectID == 0 means all projects,
|
// opts.ProjectID == 0 means all projects,
|
||||||
// do not need to apply any condition
|
// do not need to apply any condition
|
||||||
|
@ -277,3 +277,14 @@ func DiffSlice[T comparable](oldSlice, newSlice []T) (added, removed []T) {
|
|||||||
}
|
}
|
||||||
return added, removed
|
return added, removed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveValue[T comparable](a []T, target T) []T {
|
||||||
|
n := 0
|
||||||
|
for _, v := range a {
|
||||||
|
if v != target {
|
||||||
|
a[n] = v
|
||||||
|
n++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a[:n]
|
||||||
|
}
|
||||||
|
@ -551,7 +551,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID, projectID int6
|
|||||||
IssueIDs: nil,
|
IssueIDs: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
if projectID > 0 {
|
if projectID != 0 {
|
||||||
statsOpts.ProjectIDs = []int64{projectID}
|
statsOpts.ProjectIDs = []int64{projectID}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user