diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-06-20 20:38:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-20 14:38:58 +0200 |
commit | 0649c542759163899c262132f44420221e7383eb (patch) | |
tree | 1acd8f66be16229753a60e89b8b6be93bbfe5cff /models/organization/org.go | |
parent | cb50375e2b6abf0c79d4891e5e1ea775b9759cd2 (diff) | |
download | gitea-0649c542759163899c262132f44420221e7383eb.tar.gz gitea-0649c542759163899c262132f44420221e7383eb.zip |
Adjust transaction handling via db.Context (#20031)
Diffstat (limited to 'models/organization/org.go')
-rw-r--r-- | models/organization/org.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/models/organization/org.go b/models/organization/org.go index 0d4a5e337b..044ea06563 100644 --- a/models/organization/org.go +++ b/models/organization/org.go @@ -680,7 +680,7 @@ type accessibleReposEnv struct { user *user_model.User team *Team teamIDs []int64 - e db.Engine + ctx context.Context keyword string orderBy db.SearchOrderBy } @@ -706,7 +706,7 @@ func AccessibleReposEnv(ctx context.Context, org *Organization, userID int64) (A org: org, user: user, teamIDs: teamIDs, - e: db.GetEngine(ctx), + ctx: ctx, orderBy: db.SearchOrderByRecentUpdated, }, nil } @@ -717,7 +717,7 @@ func (org *Organization) AccessibleTeamReposEnv(team *Team) AccessibleReposEnvir return &accessibleReposEnv{ org: org, team: team, - e: db.GetEngine(db.DefaultContext), + ctx: db.DefaultContext, orderBy: db.SearchOrderByRecentUpdated, } } @@ -744,7 +744,7 @@ func (env *accessibleReposEnv) cond() builder.Cond { } func (env *accessibleReposEnv) CountRepos() (int64, error) { - repoCount, err := env.e. + repoCount, err := db.GetEngine(env.ctx). Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id"). Where(env.cond()). Distinct("`repository`.id"). @@ -761,7 +761,7 @@ func (env *accessibleReposEnv) RepoIDs(page, pageSize int) ([]int64, error) { } repoIDs := make([]int64, 0, pageSize) - return repoIDs, env.e. + return repoIDs, db.GetEngine(env.ctx). Table("repository"). Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id"). Where(env.cond()). @@ -783,7 +783,7 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*repo_model.Reposito return repos, nil } - return repos, env.e. + return repos, db.GetEngine(env.ctx). In("`repository`.id", repoIDs). OrderBy(string(env.orderBy)). Find(&repos) @@ -791,7 +791,7 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*repo_model.Reposito func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) { repoIDs := make([]int64, 0, 10) - return repoIDs, env.e. + return repoIDs, db.GetEngine(env.ctx). Table("repository"). Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id AND `repository`.is_mirror=?", true). Where(env.cond()). @@ -812,7 +812,7 @@ func (env *accessibleReposEnv) MirrorRepos() ([]*repo_model.Repository, error) { return repos, nil } - return repos, env.e. + return repos, db.GetEngine(env.ctx). In("`repository`.id", repoIDs). Find(&repos) } |