Remove db.DefaultContext in routers/ and cmd/ (#26076)

Now, the only remaining usages of `models.db.DefaultContext` are in
  - `modules`
  - `models`
  - `services`
This commit is contained in:
delvh 2023-07-24 05:47:27 +02:00 committed by GitHub
parent 24c3bb95ac
commit f3d41c61eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 127 additions and 134 deletions

View file

@ -5,6 +5,7 @@
package cmd
import (
"context"
"errors"
"fmt"
"net/url"
@ -373,7 +374,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
continue
}
oldnum, err := getReleaseCount(repo.ID)
oldnum, err := getReleaseCount(ctx, repo.ID)
if err != nil {
log.Warn(" GetReleaseCountByRepoID: %v", err)
}
@ -385,7 +386,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
continue
}
count, err = getReleaseCount(repo.ID)
count, err = getReleaseCount(ctx, repo.ID)
if err != nil {
log.Warn(" GetReleaseCountByRepoID: %v", err)
gitRepo.Close()
@ -401,9 +402,9 @@ func runRepoSyncReleases(_ *cli.Context) error {
return nil
}
func getReleaseCount(id int64) (int64, error) {
func getReleaseCount(ctx context.Context, id int64) (int64, error) {
return repo_model.GetReleaseCountByRepoID(
db.DefaultContext,
ctx,
id,
repo_model.FindReleasesOptions{
IncludeTags: true,