More refactoring of db.DefaultContext (#27083)

Next step of #27065
This commit is contained in:
JakobDev
2023-09-15 08:13:19 +02:00
committed by GitHub
parent f8a1094406
commit c548dde205
83 changed files with 336 additions and 320 deletions

View File

@ -24,8 +24,8 @@ func init() {
}
// StarRepo or unstar repository.
func StarRepo(userID, repoID int64, star bool) error {
ctx, committer, err := db.TxContext(db.DefaultContext)
func StarRepo(ctx context.Context, userID, repoID int64, star bool) error {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -72,8 +72,8 @@ func IsStaring(ctx context.Context, userID, repoID int64) bool {
}
// GetStargazers returns the users that starred the repo.
func GetStargazers(repo *Repository, opts db.ListOptions) ([]*user_model.User, error) {
sess := db.GetEngine(db.DefaultContext).Where("star.repo_id = ?", repo.ID).
func GetStargazers(ctx context.Context, repo *Repository, opts db.ListOptions) ([]*user_model.User, error) {
sess := db.GetEngine(ctx).Where("star.repo_id = ?", repo.ID).
Join("LEFT", "star", "`user`.id = star.uid")
if opts.Page > 0 {
sess = db.SetSessionPagination(sess, &opts)