1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Use db.Find instead of writing methods for every object (#28084)

For those simple objects, it's unnecessary to write the find and count
methods again and again.
This commit is contained in:
Lunny Xiao
2023-11-24 11:49:41 +08:00
committed by GitHub
parent d24a8223ce
commit df1e7d0067
88 changed files with 611 additions and 685 deletions

View File

@@ -75,11 +75,10 @@ func List(ctx *context.Context) {
}
// Get all runner labels
opts := actions_model.FindRunnerOptions{
runners, err := db.Find[actions_model.ActionRunner](ctx, actions_model.FindRunnerOptions{
RepoID: ctx.Repo.Repository.ID,
WithAvailable: true,
}
runners, err := actions_model.FindRunners(ctx, opts)
})
if err != nil {
ctx.ServerError("FindRunners", err)
return
@@ -169,7 +168,7 @@ func List(ctx *context.Context) {
opts.Status = []actions_model.Status{actions_model.Status(status)}
}
runs, total, err := actions_model.FindRuns(ctx, opts)
runs, total, err := db.FindAndCount[actions_model.ActionRun](ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
@@ -179,7 +178,7 @@ func List(ctx *context.Context) {
run.Repo = ctx.Repo.Repository
}
if err := runs.LoadTriggerUser(ctx); err != nil {
if err := actions_model.RunList(runs).LoadTriggerUser(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
}