loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995)

(cherry picked from commit f8ab9dafb7a173a35e9308f8f784735b0f822439)

Conflicts:
routers/web/repo/fork.go
trivial context conflict, the file does not exist in Forgejo

authored by

Lunny Xiao and committed by
Earl Warren
196c8772 c97a7b83

+41 -77
+16 -32
modules/indexer/issues/internal/tests/tests.go
··· 515 515 { 516 516 Name: "SortByCreatedDesc", 517 517 SearchOptions: &internal.SearchOptions{ 518 - Paginator: &db.ListOptions{ 519 - ListAll: true, 520 - }, 521 - SortBy: internal.SortByCreatedDesc, 518 + Paginator: &db.ListOptionsAll, 519 + SortBy: internal.SortByCreatedDesc, 522 520 }, 523 521 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 524 522 assert.Equal(t, len(data), len(result.Hits)) ··· 533 531 { 534 532 Name: "SortByUpdatedDesc", 535 533 SearchOptions: &internal.SearchOptions{ 536 - Paginator: &db.ListOptions{ 537 - ListAll: true, 538 - }, 539 - SortBy: internal.SortByUpdatedDesc, 534 + Paginator: &db.ListOptionsAll, 535 + SortBy: internal.SortByUpdatedDesc, 540 536 }, 541 537 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 542 538 assert.Equal(t, len(data), len(result.Hits)) ··· 551 547 { 552 548 Name: "SortByCommentsDesc", 553 549 SearchOptions: &internal.SearchOptions{ 554 - Paginator: &db.ListOptions{ 555 - ListAll: true, 556 - }, 557 - SortBy: internal.SortByCommentsDesc, 550 + Paginator: &db.ListOptionsAll, 551 + SortBy: internal.SortByCommentsDesc, 558 552 }, 559 553 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 560 554 assert.Equal(t, len(data), len(result.Hits)) ··· 569 563 { 570 564 Name: "SortByDeadlineDesc", 571 565 SearchOptions: &internal.SearchOptions{ 572 - Paginator: &db.ListOptions{ 573 - ListAll: true, 574 - }, 575 - SortBy: internal.SortByDeadlineDesc, 566 + Paginator: &db.ListOptionsAll, 567 + SortBy: internal.SortByDeadlineDesc, 576 568 }, 577 569 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 578 570 assert.Equal(t, len(data), len(result.Hits)) ··· 587 579 { 588 580 Name: "SortByCreatedAsc", 589 581 SearchOptions: &internal.SearchOptions{ 590 - Paginator: &db.ListOptions{ 591 - ListAll: true, 592 - }, 593 - SortBy: internal.SortByCreatedAsc, 582 + Paginator: &db.ListOptionsAll, 583 + SortBy: internal.SortByCreatedAsc, 594 584 }, 595 585 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 596 586 assert.Equal(t, len(data), len(result.Hits)) ··· 605 595 { 606 596 Name: "SortByUpdatedAsc", 607 597 SearchOptions: &internal.SearchOptions{ 608 - Paginator: &db.ListOptions{ 609 - ListAll: true, 610 - }, 611 - SortBy: internal.SortByUpdatedAsc, 598 + Paginator: &db.ListOptionsAll, 599 + SortBy: internal.SortByUpdatedAsc, 612 600 }, 613 601 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 614 602 assert.Equal(t, len(data), len(result.Hits)) ··· 623 611 { 624 612 Name: "SortByCommentsAsc", 625 613 SearchOptions: &internal.SearchOptions{ 626 - Paginator: &db.ListOptions{ 627 - ListAll: true, 628 - }, 629 - SortBy: internal.SortByCommentsAsc, 614 + Paginator: &db.ListOptionsAll, 615 + SortBy: internal.SortByCommentsAsc, 630 616 }, 631 617 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 632 618 assert.Equal(t, len(data), len(result.Hits)) ··· 641 627 { 642 628 Name: "SortByDeadlineAsc", 643 629 SearchOptions: &internal.SearchOptions{ 644 - Paginator: &db.ListOptions{ 645 - ListAll: true, 646 - }, 647 - SortBy: internal.SortByDeadlineAsc, 630 + Paginator: &db.ListOptionsAll, 631 + SortBy: internal.SortByDeadlineAsc, 648 632 }, 649 633 Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) { 650 634 assert.Equal(t, len(data), len(result.Hits))
+1 -3
modules/indexer/issues/util.go
··· 61 61 ) 62 62 { 63 63 reviews, err := issue_model.FindReviews(ctx, issue_model.FindReviewOptions{ 64 - ListOptions: db.ListOptions{ 65 - ListAll: true, 66 - }, 64 + ListOptions: db.ListOptionsAll, 67 65 IssueID: issueID, 68 66 OfficialOnly: false, 69 67 })
+2 -6
routers/web/admin/users.go
··· 275 275 } 276 276 277 277 repos, count, err := repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{ 278 - ListOptions: db.ListOptions{ 279 - ListAll: true, 280 - }, 278 + ListOptions: db.ListOptionsAll, 281 279 OwnerID: u.ID, 282 280 OrderBy: db.SearchOrderByAlphabetically, 283 281 Private: true, ··· 300 298 ctx.Data["EmailsTotal"] = len(emails) 301 299 302 300 orgs, err := db.Find[org_model.Organization](ctx, org_model.FindOrgOptions{ 303 - ListOptions: db.ListOptions{ 304 - ListAll: true, 305 - }, 301 + ListOptions: db.ListOptionsAll, 306 302 UserID: u.ID, 307 303 IncludePrivate: true, 308 304 })
+1 -1
routers/web/repo/commit.go
··· 367 367 ctx.Data["Commit"] = commit 368 368 ctx.Data["Diff"] = diff 369 369 370 - statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptions{ListAll: true}) 370 + statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptionsAll) 371 371 if err != nil { 372 372 log.Error("GetLatestCommitStatus: %v", err) 373 373 }
+4 -8
routers/web/repo/compare.go
··· 697 697 defer gitRepo.Close() 698 698 699 699 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, 704 702 IsDeletedBranch: optional.Some(false), 705 703 }) 706 704 if err != nil { ··· 754 752 } 755 753 756 754 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, 761 757 IsDeletedBranch: optional.Some(false), 762 758 }) 763 759 if err != nil {
+3 -3
routers/web/repo/pull.go
··· 505 505 506 506 if len(compareInfo.Commits) != 0 { 507 507 sha := compareInfo.Commits[0].ID.String() 508 - commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{ListAll: true}) 508 + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptionsAll) 509 509 if err != nil { 510 510 ctx.ServerError("GetLatestCommitStatus", err) 511 511 return nil ··· 567 567 ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err) 568 568 return nil 569 569 } 570 - commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}) 570 + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll) 571 571 if err != nil { 572 572 ctx.ServerError("GetLatestCommitStatus", err) 573 573 return nil ··· 659 659 return nil 660 660 } 661 661 662 - commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}) 662 + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll) 663 663 if err != nil { 664 664 ctx.ServerError("GetLatestCommitStatus", err) 665 665 return nil
+1 -1
routers/web/repo/release.go
··· 136 136 } 137 137 138 138 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) 140 140 if err != nil { 141 141 return nil, err 142 142 }
+2 -6
routers/web/repo/repo.go
··· 684 684 branchOpts := git_model.FindBranchOptions{ 685 685 RepoID: ctx.Repo.Repository.ID, 686 686 IsDeletedBranch: optional.Some(false), 687 - ListOptions: db.ListOptions{ 688 - ListAll: true, 689 - }, 687 + ListOptions: db.ListOptionsAll, 690 688 } 691 689 branches, err := git_model.FindBranchNames(ctx, branchOpts) 692 690 if err != nil { ··· 719 717 branchOpts := git_model.FindBranchOptions{ 720 718 RepoID: ctx.Repo.Repository.ID, 721 719 IsDeletedBranch: optional.Some(false), 722 - ListOptions: db.ListOptions{ 723 - ListAll: true, 724 - }, 720 + ListOptions: db.ListOptionsAll, 725 721 } 726 722 brs, err := git_model.FindBranchNames(ctx, branchOpts) 727 723 if err != nil {
+1 -1
routers/web/repo/view.go
··· 364 364 ctx.Data["LatestCommitVerification"] = verification 365 365 ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(ctx, latestCommit) 366 366 367 - statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{ListAll: true}) 367 + statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptionsAll) 368 368 if err != nil { 369 369 log.Error("GetLatestCommitStatus: %v", err) 370 370 }
+1 -1
services/actions/commit_status.go
··· 79 79 } 80 80 ctxname := fmt.Sprintf("%s / %s (%s)", runName, job.Name, event) 81 81 state := toCommitStatus(job.Status) 82 - if statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{ListAll: true}); err == nil { 82 + if statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptionsAll); err == nil { 83 83 for _, v := range statuses { 84 84 if v.Context == ctxname { 85 85 if v.State == state {
+1 -1
services/pull/commit_status.go
··· 153 153 return "", fmt.Errorf("LoadBaseRepo: %w", err) 154 154 } 155 155 156 - commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true}) 156 + commitStatuses, _, err := git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptionsAll) 157 157 if err != nil { 158 158 return "", fmt.Errorf("GetLatestCommitStatus: %w", err) 159 159 }
+1 -1
services/pull/pull.go
··· 893 893 return nil, nil, shaErr 894 894 } 895 895 896 - statuses, _, err = git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptions{ListAll: true}) 896 + statuses, _, err = git_model.GetLatestCommitStatus(ctx, pr.BaseRepo.ID, sha, db.ListOptionsAll) 897 897 lastStatus = git_model.CalcCommitStatus(statuses) 898 898 return statuses, lastStatus, err 899 899 }
+5 -9
services/pull/review.go
··· 52 52 issueIDs := prs.GetIssueIDs() 53 53 54 54 codeComments, err := db.Find[issues_model.Comment](ctx, issues_model.FindCommentsOptions{ 55 - ListOptions: db.ListOptions{ 56 - ListAll: true, 57 - }, 55 + ListOptions: db.ListOptionsAll, 58 56 Type: issues_model.CommentTypeCode, 59 57 Invalidated: optional.Some(false), 60 58 IssueIDs: issueIDs, ··· 322 320 // DismissApprovalReviews dismiss all approval reviews because of new commits 323 321 func DismissApprovalReviews(ctx context.Context, doer *user_model.User, pull *issues_model.PullRequest) error { 324 322 reviews, err := issues_model.FindReviews(ctx, issues_model.FindReviewOptions{ 325 - ListOptions: db.ListOptions{ 326 - ListAll: true, 327 - }, 328 - IssueID: pull.IssueID, 329 - Type: issues_model.ReviewTypeApprove, 330 - Dismissed: optional.Some(false), 323 + ListOptions: db.ListOptionsAll, 324 + IssueID: pull.IssueID, 325 + Type: issues_model.ReviewTypeApprove, 326 + Dismissed: optional.Some(false), 331 327 }) 332 328 if err != nil { 333 329 return err
+2 -4
services/repository/adopt.go
··· 144 144 } 145 145 146 146 branches, _ := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{ 147 - RepoID: repo.ID, 148 - ListOptions: db.ListOptions{ 149 - ListAll: true, 150 - }, 147 + RepoID: repo.ID, 148 + ListOptions: db.ListOptionsAll, 151 149 IsDeletedBranch: optional.Some(false), 152 150 }) 153 151