mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Merge db.Iterate and IterateObjects (#21641)
These two functions are similiar, merge them.
This commit is contained in:
@@ -18,10 +18,9 @@ import (
|
||||
func iterateUserAccounts(ctx context.Context, each func(*user.User) error) error {
|
||||
err := db.Iterate(
|
||||
ctx,
|
||||
new(user.User),
|
||||
builder.Gt{"id": 0},
|
||||
func(idx int, bean interface{}) error {
|
||||
return each(bean.(*user.User))
|
||||
func(ctx context.Context, bean *user.User) error {
|
||||
return each(bean)
|
||||
},
|
||||
)
|
||||
return err
|
||||
|
@@ -269,13 +269,10 @@ func fixBrokenRepoUnits16961(ctx context.Context, logger log.Logger, autofix boo
|
||||
|
||||
err := db.Iterate(
|
||||
ctx,
|
||||
new(RepoUnit),
|
||||
builder.Gt{
|
||||
"id": 0,
|
||||
},
|
||||
func(idx int, bean interface{}) error {
|
||||
unit := bean.(*RepoUnit)
|
||||
|
||||
func(ctx context.Context, unit *RepoUnit) error {
|
||||
bs := unit.Config
|
||||
repoUnit := &repo_model.RepoUnit{
|
||||
ID: unit.ID,
|
||||
|
@@ -21,10 +21,9 @@ import (
|
||||
func iteratePRs(ctx context.Context, repo *repo_model.Repository, each func(*repo_model.Repository, *issues_model.PullRequest) error) error {
|
||||
return db.Iterate(
|
||||
ctx,
|
||||
new(issues_model.PullRequest),
|
||||
builder.Eq{"base_repo_id": repo.ID},
|
||||
func(idx int, bean interface{}) error {
|
||||
return each(repo, bean.(*issues_model.PullRequest))
|
||||
func(ctx context.Context, bean *issues_model.PullRequest) error {
|
||||
return each(repo, bean)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@@ -30,10 +30,9 @@ import (
|
||||
func iterateRepositories(ctx context.Context, each func(*repo_model.Repository) error) error {
|
||||
err := db.Iterate(
|
||||
ctx,
|
||||
new(repo_model.Repository),
|
||||
builder.Gt{"id": 0},
|
||||
func(idx int, bean interface{}) error {
|
||||
return each(bean.(*repo_model.Repository))
|
||||
func(ctx context.Context, bean *repo_model.Repository) error {
|
||||
return each(bean)
|
||||
},
|
||||
)
|
||||
return err
|
||||
|
Reference in New Issue
Block a user