Skip to content

Commit f8ab9da

Browse files
authored
Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995)
1 parent 2911874 commit f8ab9da

File tree

15 files changed

+43
-81
lines changed

15 files changed

+43
-81
lines changed

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

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,8 @@ var cases = []*testIndexerCase{
515515
{
516516
Name: "SortByCreatedDesc",
517517
SearchOptions: &internal.SearchOptions{
518-
Paginator: &db.ListOptions{
519-
ListAll: true,
520-
},
521-
SortBy: internal.SortByCreatedDesc,
518+
Paginator: &db.ListOptionsAll,
519+
SortBy: internal.SortByCreatedDesc,
522520
},
523521
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
524522
assert.Equal(t, len(data), len(result.Hits))
@@ -533,10 +531,8 @@ var cases = []*testIndexerCase{
533531
{
534532
Name: "SortByUpdatedDesc",
535533
SearchOptions: &internal.SearchOptions{
536-
Paginator: &db.ListOptions{
537-
ListAll: true,
538-
},
539-
SortBy: internal.SortByUpdatedDesc,
534+
Paginator: &db.ListOptionsAll,
535+
SortBy: internal.SortByUpdatedDesc,
540536
},
541537
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
542538
assert.Equal(t, len(data), len(result.Hits))
@@ -551,10 +547,8 @@ var cases = []*testIndexerCase{
551547
{
552548
Name: "SortByCommentsDesc",
553549
SearchOptions: &internal.SearchOptions{
554-
Paginator: &db.ListOptions{
555-
ListAll: true,
556-
},
557-
SortBy: internal.SortByCommentsDesc,
550+
Paginator: &db.ListOptionsAll,
551+
SortBy: internal.SortByCommentsDesc,
558552
},
559553
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
560554
assert.Equal(t, len(data), len(result.Hits))
@@ -569,10 +563,8 @@ var cases = []*testIndexerCase{
569563
{
570564
Name: "SortByDeadlineDesc",
571565
SearchOptions: &internal.SearchOptions{
572-
Paginator: &db.ListOptions{
573-
ListAll: true,
574-
},
575-
SortBy: internal.SortByDeadlineDesc,
566+
Paginator: &db.ListOptionsAll,
567+
SortBy: internal.SortByDeadlineDesc,
576568
},
577569
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
578570
assert.Equal(t, len(data), len(result.Hits))
@@ -587,10 +579,8 @@ var cases = []*testIndexerCase{
587579
{
588580
Name: "SortByCreatedAsc",
589581
SearchOptions: &internal.SearchOptions{
590-
Paginator: &db.ListOptions{
591-
ListAll: true,
592-
},
593-
SortBy: internal.SortByCreatedAsc,
582+
Paginator: &db.ListOptionsAll,
583+
SortBy: internal.SortByCreatedAsc,
594584
},
595585
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
596586
assert.Equal(t, len(data), len(result.Hits))
@@ -605,10 +595,8 @@ var cases = []*testIndexerCase{
605595
{
606596
Name: "SortByUpdatedAsc",
607597
SearchOptions: &internal.SearchOptions{
608-
Paginator: &db.ListOptions{
609-
ListAll: true,
610-
},
611-
SortBy: internal.SortByUpdatedAsc,
598+
Paginator: &db.ListOptionsAll,
599+
SortBy: internal.SortByUpdatedAsc,
612600
},
613601
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
614602
assert.Equal(t, len(data), len(result.Hits))
@@ -623,10 +611,8 @@ var cases = []*testIndexerCase{
623611
{
624612
Name: "SortByCommentsAsc",
625613
SearchOptions: &internal.SearchOptions{
626-
Paginator: &db.ListOptions{
627-
ListAll: true,
628-
},
629-
SortBy: internal.SortByCommentsAsc,
614+
Paginator: &db.ListOptionsAll,
615+
SortBy: internal.SortByCommentsAsc,
630616
},
631617
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
632618
assert.Equal(t, len(data), len(result.Hits))
@@ -641,10 +627,8 @@ var cases = []*testIndexerCase{
641627
{
642628
Name: "SortByDeadlineAsc",
643629
SearchOptions: &internal.SearchOptions{
644-
Paginator: &db.ListOptions{
645-
ListAll: true,
646-
},
647-
SortBy: internal.SortByDeadlineAsc,
630+
Paginator: &db.ListOptionsAll,
631+
SortBy: internal.SortByDeadlineAsc,
648632
},
649633
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
650634
assert.Equal(t, len(data), len(result.Hits))

modules/indexer/issues/util.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD
6161
)
6262
{
6363
reviews, err := issue_model.FindReviews(ctx, issue_model.FindReviewOptions{
64-
ListOptions: db.ListOptions{
65-
ListAll: true,
66-
},
64+
ListOptions: db.ListOptionsAll,
6765
IssueID: issueID,
6866
OfficialOnly: false,
6967
})

routers/web/admin/users.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ func ViewUser(ctx *context.Context) {
275275
}
276276

277277
repos, count, err := repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
278-
ListOptions: db.ListOptions{
279-
ListAll: true,
280-
},
278+
ListOptions: db.ListOptionsAll,
281279
OwnerID: u.ID,
282280
OrderBy: db.SearchOrderByAlphabetically,
283281
Private: true,
@@ -300,9 +298,7 @@ func ViewUser(ctx *context.Context) {
300298
ctx.Data["EmailsTotal"] = len(emails)
301299

302300
orgs, err := db.Find[org_model.Organization](ctx, org_model.FindOrgOptions{
303-
ListOptions: db.ListOptions{
304-
ListAll: true,
305-
},
301+
ListOptions: db.ListOptionsAll,
306302
UserID: u.ID,
307303
IncludePrivate: true,
308304
})

routers/web/repo/commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func Diff(ctx *context.Context) {
351351
ctx.Data["Commit"] = commit
352352
ctx.Data["Diff"] = diff
353353

354-
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptions{ListAll: true})
354+
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptionsAll)
355355
if err != nil {
356356
log.Error("GetLatestCommitStatus: %v", err)
357357
}

routers/web/repo/compare.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,8 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
697697
defer gitRepo.Close()
698698

699699
branches, err = git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
700-
RepoID: repo.ID,
701-
ListOptions: db.ListOptions{
702-
ListAll: true,
703-
},
700+
RepoID: repo.ID,
701+
ListOptions: db.ListOptionsAll,
704702
IsDeletedBranch: optional.Some(false),
705703
})
706704
if err != nil {
@@ -754,10 +752,8 @@ func CompareDiff(ctx *context.Context) {
754752
}
755753

756754
headBranches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
757-
RepoID: ci.HeadRepo.ID,
758-
ListOptions: db.ListOptions{
759-
ListAll: true,
760-
},
755+
RepoID: ci.HeadRepo.ID,
756+
ListOptions: db.ListOptionsAll,
761757
IsDeletedBranch: optional.Some(false),
762758
})
763759
if err != nil {

routers/web/repo/fork.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
101101
}
102102

103103
branches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{
104-
RepoID: ctx.Repo.Repository.ID,
105-
ListOptions: db.ListOptions{
106-
ListAll: true,
107-
},
104+
RepoID: ctx.Repo.Repository.ID,
105+
ListOptions: db.ListOptionsAll,
108106
IsDeletedBranch: optional.Some(false),
109107
// Add it as the first option
110108
ExcludeBranchNames: []string{ctx.Repo.Repository.DefaultBranch},

routers/web/repo/pull.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *issues_model.Issue)
278278

279279
if len(compareInfo.Commits) != 0 {
280280
sha := compareInfo.Commits[0].ID.String()
281-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{ListAll: true})
281+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptionsAll)
282282
if err != nil {
283283
ctx.ServerError("GetLatestCommitStatus", err)
284284
return nil
@@ -340,7 +340,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
340340
ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err)
341341
return nil
342342
}
343-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
343+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll)
344344
if err != nil {
345345
ctx.ServerError("GetLatestCommitStatus", err)
346346
return nil
@@ -432,7 +432,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
432432
return nil
433433
}
434434

435-
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true})
435+
commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll)
436436
if err != nil {
437437
ctx.ServerError("GetLatestCommitStatus", err)
438438
return nil

routers/web/repo/release.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func getReleaseInfos(ctx *context.Context, opts *repo_model.FindReleasesOptions)
136136
}
137137

138138
if canReadActions {
139-
statuses, _, err := git_model.GetLatestCommitStatus(ctx, r.Repo.ID, r.Sha1, db.ListOptions{ListAll: true})
139+
statuses, _, err := git_model.GetLatestCommitStatus(ctx, r.Repo.ID, r.Sha1, db.ListOptionsAll)
140140
if err != nil {
141141
return nil, err
142142
}

routers/web/repo/repo.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,7 @@ func GetBranchesList(ctx *context.Context) {
688688
branchOpts := git_model.FindBranchOptions{
689689
RepoID: ctx.Repo.Repository.ID,
690690
IsDeletedBranch: optional.Some(false),
691-
ListOptions: db.ListOptions{
692-
ListAll: true,
693-
},
691+
ListOptions: db.ListOptionsAll,
694692
}
695693
branches, err := git_model.FindBranchNames(ctx, branchOpts)
696694
if err != nil {
@@ -723,9 +721,7 @@ func PrepareBranchList(ctx *context.Context) {
723721
branchOpts := git_model.FindBranchOptions{
724722
RepoID: ctx.Repo.Repository.ID,
725723
IsDeletedBranch: optional.Some(false),
726-
ListOptions: db.ListOptions{
727-
ListAll: true,
728-
},
724+
ListOptions: db.ListOptionsAll,
729725
}
730726
brs, err := git_model.FindBranchNames(ctx, branchOpts)
731727
if err != nil {

routers/web/repo/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func loadLatestCommitData(ctx *context.Context, latestCommit *git.Commit) bool {
359359
ctx.Data["LatestCommitVerification"] = verification
360360
ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(ctx, latestCommit)
361361

362-
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{ListAll: true})
362+
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptionsAll)
363363
if err != nil {
364364
log.Error("GetLatestCommitStatus: %v", err)
365365
}

0 commit comments

Comments
 (0)