Skip to content

Commit 9576848

Browse files
committed
fix test and comment
1 parent 330c7e2 commit 9576848

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

models/issues/issue_search.go

+2
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ func applyAssigneeCondition(sess *xorm.Session, assigneeID string) {
369369
}
370370

371371
func applyPosterCondition(sess *xorm.Session, posterID string) {
372+
// Actually every issue has a poster.
373+
// The "(none)" is for internal usage only: when doer tries to search non-existing user as poster, use "(none)" to return empty result.
372374
if posterID == "(none)" {
373375
sess.And("issue.poster_id=0")
374376
} else if posterIDInt64, _ := strconv.ParseInt(posterID, 10, 64); posterIDInt64 > 0 {

models/issues/issue_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
repo_model "code.gitea.io/gitea/models/repo"
1616
"code.gitea.io/gitea/models/unittest"
1717
user_model "code.gitea.io/gitea/models/user"
18-
"code.gitea.io/gitea/modules/optional"
1918
"code.gitea.io/gitea/modules/setting"
2019

2120
"github.com/stretchr/testify/assert"
@@ -155,7 +154,7 @@ func TestIssues(t *testing.T) {
155154
}{
156155
{
157156
issues_model.IssuesOptions{
158-
AssigneeID: optional.Some(int64(1)),
157+
AssigneeID: "1",
159158
SortType: "oldest",
160159
},
161160
[]int64{1, 6},

modules/indexer/issues/indexer_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,19 @@ func searchIssueByID(t *testing.T) {
177177
}{
178178
{
179179
opts: SearchOptions{
180-
PosterID: optional.Some(int64(1)),
180+
PosterID: "1",
181181
},
182182
expectedIDs: []int64{11, 6, 3, 2, 1},
183183
},
184184
{
185185
opts: SearchOptions{
186-
AssigneeID: optional.Some(int64(1)),
186+
AssigneeID: "1",
187187
},
188188
expectedIDs: []int64{6, 1},
189189
},
190190
{
191-
// NOTE: This tests no assignees filtering and also ToSearchOptions() to ensure it will set AssigneeID to 0 when it is passed as -1.
192-
opts: *ToSearchOptions("", &issues.IssuesOptions{AssigneeID: optional.Some(db.NoConditionID)}),
191+
// NOTE: This tests no assignees filtering and also ToSearchOptions() to ensure it handles the filter correctly
192+
opts: *ToSearchOptions("", &issues.IssuesOptions{AssigneeID: "(none)"}),
193193
expectedIDs: []int64{22, 21, 16, 15, 14, 13, 12, 11, 20, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2},
194194
},
195195
{
@@ -472,7 +472,7 @@ func searchIssueWithAnyAssignee(t *testing.T) {
472472
}{
473473
{
474474
SearchOptions{
475-
AnyAssigneeOnly: true,
475+
AssigneeID: "(any)",
476476
},
477477
[]int64{17, 6, 1},
478478
3,

modules/indexer/issues/internal/tests/tests.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ var cases = []*testIndexerCase{
379379
Paginator: &db.ListOptions{
380380
PageSize: 5,
381381
},
382-
PosterID: optional.Some(int64(1)),
382+
PosterID: "1",
383383
},
384384
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
385385
assert.Len(t, result.Hits, 5)
@@ -397,7 +397,7 @@ var cases = []*testIndexerCase{
397397
Paginator: &db.ListOptions{
398398
PageSize: 5,
399399
},
400-
AssigneeID: optional.Some(int64(1)),
400+
AssigneeID: "1",
401401
},
402402
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
403403
assert.Len(t, result.Hits, 5)
@@ -415,7 +415,7 @@ var cases = []*testIndexerCase{
415415
Paginator: &db.ListOptions{
416416
PageSize: 5,
417417
},
418-
AssigneeID: optional.Some(int64(0)),
418+
AssigneeID: "(none)",
419419
},
420420
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
421421
assert.Len(t, result.Hits, 5)
@@ -650,7 +650,7 @@ var cases = []*testIndexerCase{
650650
{
651651
Name: "SearchAnyAssignee",
652652
SearchOptions: &internal.SearchOptions{
653-
AnyAssigneeOnly: true,
653+
AssigneeID: "(any)",
654654
},
655655
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
656656
assert.Len(t, result.Hits, 180)

routers/api/v1/repo/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ func ListIssues(ctx *context.APIContext) {
541541
searchOpt.PosterID = strconv.FormatInt(createdByID, 10)
542542
}
543543
if assignedByID > 0 {
544-
searchOpt.AssigneeID = strconv.FormatInt(assignedByID, 64)
544+
searchOpt.AssigneeID = strconv.FormatInt(assignedByID, 10)
545545
}
546546
if mentionedByID > 0 {
547547
searchOpt.MentionID = optional.Some(mentionedByID)

routers/web/shared/user/helper.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func GetFilterUserIDByName(ctx context.Context, name string) string {
4444
if id, err := strconv.ParseInt(name, 10, 64); err == nil {
4545
return strconv.FormatInt(id, 10)
4646
}
47+
// The "(none)" is for internal usage only: when doer tries to search non-existing user, use "(none)" to return empty result.
4748
return "(none)"
4849
}
4950
return strconv.FormatInt(u.ID, 10)

templates/repo/issue/filter_item_user_assign.tmpl

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
* UserSearchList
55
* SelectedUserId: 0 or empty means default, -1 means "no user is set"
66
* TextFilterTitle
7-
* TextZeroValue: the text for "all issues"
8-
* TextNegativeOne: the text for "issues with no assignee"
9-
* TextAnyCondition: the text for "issues with any assignee"
7+
* TextFilterMatchNone: the text for "issues with no assignee"
8+
* TextFilterMatchAny: the text for "issues with any assignee"
109
*/}}
1110
{{$queryLink := .QueryLink}}
1211
<div class="item ui dropdown jump {{if not .UserSearchList}}disabled{{end}}">

0 commit comments

Comments
 (0)