Second part of refactor db.Find (#28194)

Continue of #27798 and move more functions to `db.Find` and `db.Count`.
This commit is contained in:
Lunny Xiao 2023-12-11 16:56:48 +08:00 committed by GitHub
parent 0abb5633e3
commit 537fa69962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 149 additions and 222 deletions

View file

@ -668,11 +668,9 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
branchOpts := git_model.FindBranchOptions{
RepoID: ctx.Repo.Repository.ID,
IsDeletedBranch: util.OptionalBoolFalse,
ListOptions: db.ListOptions{
ListAll: true,
},
ListOptions: db.ListOptionsAll,
}
branchesTotal, err := git_model.CountBranches(ctx, branchOpts)
branchesTotal, err := db.Count[git_model.Branch](ctx, branchOpts)
if err != nil {
ctx.ServerError("CountBranches", err)
return cancel

View file

@ -49,11 +49,9 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository,
dbBranches := make(map[string]*git_model.Branch)
{
branches, err := git_model.FindBranches(ctx, git_model.FindBranchOptions{
ListOptions: db.ListOptions{
ListAll: true,
},
RepoID: repo.ID,
branches, err := db.Find[git_model.Branch](ctx, git_model.FindBranchOptions{
ListOptions: db.ListOptionsAll,
RepoID: repo.ID,
})
if err != nil {
return 0, err