summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-10-11 06:24:07 +0200
committerGitHub <noreply@github.com>2023-10-11 04:24:07 +0000
commitebe803e514acb4eedc884226be2489ee6b4acd28 (patch)
tree3f4d38f8267142dcd0e8df7d76cd4fe04c47b85e /models/repo.go
parent50166d1f7c6df41c79561b094e29c9698c0000d5 (diff)
downloadgitea-ebe803e514acb4eedc884226be2489ee6b4acd28.tar.gz
gitea-ebe803e514acb4eedc884226be2489ee6b4acd28.zip
Penultimate round of `db.DefaultContext` refactor (#27414)
Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/repo.go b/models/repo.go
index 82433ca055..d525264b3b 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -277,8 +277,8 @@ func UpdateRepoStats(ctx context.Context, id int64) error {
return nil
}
-func updateUserStarNumbers(users []user_model.User) error {
- ctx, committer, err := db.TxContext(db.DefaultContext)
+func updateUserStarNumbers(ctx context.Context, users []user_model.User) error {
+ ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@@ -294,19 +294,19 @@ func updateUserStarNumbers(users []user_model.User) error {
}
// DoctorUserStarNum recalculate Stars number for all user
-func DoctorUserStarNum() (err error) {
+func DoctorUserStarNum(ctx context.Context) (err error) {
const batchSize = 100
for start := 0; ; start += batchSize {
users := make([]user_model.User, 0, batchSize)
- if err = db.GetEngine(db.DefaultContext).Limit(batchSize, start).Where("type = ?", 0).Cols("id").Find(&users); err != nil {
+ if err = db.GetEngine(ctx).Limit(batchSize, start).Where("type = ?", 0).Cols("id").Find(&users); err != nil {
return err
}
if len(users) == 0 {
break
}
- if err = updateUserStarNumbers(users); err != nil {
+ if err = updateUserStarNumbers(ctx, users); err != nil {
return err
}
}