Skip to content

Commit d00558f

Browse files
committed
Fix filter no project and attach project no work issue
1 parent 6d268cd commit d00558f

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

models/db/search.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ const (
3737
// Which means a condition to filter the records which don't match any id.
3838
// It's different from zero which means the condition could be ignored.
3939
NoConditionID = -1
40+
NoProjectID = -1
4041
)

models/issues/issue_project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_mo
123123
}{}
124124
if _, err := db.GetEngine(ctx).Select("count(*) as issue_count").Table("project_issue").
125125
Where("project_id=?", newProjectID).
126-
And("project_board_id=?", newColumnID).
126+
And("issue_id=?", issue.ID).
127127
Get(&res); err != nil {
128128
return err
129129
}

modules/indexer/issues/db/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
8484
opts.MilestoneIDs = options.MilestoneIDs
8585
}
8686

87+
if len(options.ProjectIDs) == 1 {
88+
if options.ProjectIDs[0] == 0 {
89+
opts.ProjectID = db.NoProjectID
90+
} else {
91+
opts.ProjectID = options.ProjectIDs[0]
92+
}
93+
}
94+
8795
if options.NoLabelOnly {
8896
opts.LabelIDs = []int64{0} // Be careful, it's zero, not db.NoConditionID
8997
} else {

modules/indexer/issues/dboptions.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
4949
return nil
5050
}
5151

52-
searchOpt.ProjectIDs = convertID(opts.ProjectID)
52+
if opts.ProjectID == db.NoProjectID {
53+
searchOpt.ProjectIDs = []int64{0}
54+
} else {
55+
searchOpt.ProjectIDs = convertID(opts.ProjectID)
56+
}
57+
5358
searchOpt.ProjectColumnID = convertID(opts.ProjectColumnID)
5459
searchOpt.PosterID = convertID(opts.PosterID)
5560
searchOpt.AssigneeID = convertID(opts.AssigneeID)

0 commit comments

Comments
 (0)