summaryrefslogtreecommitdiffstats
path: root/models/fixture_generation.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-10-15 23:46:06 +0800
committerGitHub <noreply@github.com>2023-10-15 17:46:06 +0200
commitcddf245c12223c783c856c87c21cc796ac425439 (patch)
tree21edf50797c62c3e70dbada95edc20d7ddfd53b8 /models/fixture_generation.go
parent7480aacdad9470458fa0142beab54b8011bbac25 (diff)
downloadgitea-cddf245c12223c783c856c87c21cc796ac425439.tar.gz
gitea-cddf245c12223c783c856c87c21cc796ac425439.zip
Replace more db.DefaultContext (#27628)
Target #27065
Diffstat (limited to 'models/fixture_generation.go')
-rw-r--r--models/fixture_generation.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/models/fixture_generation.go b/models/fixture_generation.go
index d342919895..6234caefad 100644
--- a/models/fixture_generation.go
+++ b/models/fixture_generation.go
@@ -4,6 +4,7 @@
package models
import (
+ "context"
"fmt"
"strings"
@@ -14,15 +15,15 @@ import (
// GetYamlFixturesAccess returns a string containing the contents
// for the access table, as recalculated using repo.RecalculateAccesses()
-func GetYamlFixturesAccess() (string, error) {
+func GetYamlFixturesAccess(ctx context.Context) (string, error) {
repos := make([]*repo_model.Repository, 0, 50)
- if err := db.GetEngine(db.DefaultContext).Find(&repos); err != nil {
+ if err := db.GetEngine(ctx).Find(&repos); err != nil {
return "", err
}
for _, repo := range repos {
- repo.MustOwner(db.DefaultContext)
- if err := access_model.RecalculateAccesses(db.DefaultContext, repo); err != nil {
+ repo.MustOwner(ctx)
+ if err := access_model.RecalculateAccesses(ctx, repo); err != nil {
return "", err
}
}
@@ -30,7 +31,7 @@ func GetYamlFixturesAccess() (string, error) {
var b strings.Builder
accesses := make([]*access_model.Access, 0, 200)
- if err := db.GetEngine(db.DefaultContext).OrderBy("user_id, repo_id").Find(&accesses); err != nil {
+ if err := db.GetEngine(ctx).OrderBy("user_id, repo_id").Find(&accesses); err != nil {
return "", err
}