summaryrefslogtreecommitdiffstats
path: root/routers/web/shared/actions/runners.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-11-24 04:49:41 +0100
committerGitHub <noreply@github.com>2023-11-24 04:49:41 +0100
commitdf1e7d0067bb39913eb681ccc920649884fb1938 (patch)
tree2419feab5c28658adb7f71878df646bdc9bdc50e /routers/web/shared/actions/runners.go
parentEdit Discord Badge (#28188) (diff)
downloadforgejo-df1e7d0067bb39913eb681ccc920649884fb1938.tar.xz
forgejo-df1e7d0067bb39913eb681ccc920649884fb1938.zip
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.
Diffstat (limited to 'routers/web/shared/actions/runners.go')
-rw-r--r--routers/web/shared/actions/runners.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go
index 1da4ddf14f..ae9a376724 100644
--- a/routers/web/shared/actions/runners.go
+++ b/routers/web/shared/actions/runners.go
@@ -17,18 +17,13 @@ import (
// RunnersList prepares data for runners list
func RunnersList(ctx *context.Context, opts actions_model.FindRunnerOptions) {
- count, err := actions_model.CountRunners(ctx, opts)
+ runners, count, err := db.FindAndCount[actions_model.ActionRunner](ctx, opts)
if err != nil {
ctx.ServerError("CountRunners", err)
return
}
- runners, err := actions_model.FindRunners(ctx, opts)
- if err != nil {
- ctx.ServerError("FindRunners", err)
- return
- }
- if err := runners.LoadAttributes(ctx); err != nil {
+ if err := actions_model.RunnerList(runners).LoadAttributes(ctx); err != nil {
ctx.ServerError("LoadAttributes", err)
return
}
@@ -89,18 +84,13 @@ func RunnerDetails(ctx *context.Context, page int, runnerID, ownerID, repoID int
RunnerID: runner.ID,
}
- count, err := actions_model.CountTasks(ctx, opts)
+ tasks, count, err := db.FindAndCount[actions_model.ActionTask](ctx, opts)
if err != nil {
ctx.ServerError("CountTasks", err)
return
}
- tasks, err := actions_model.FindTasks(ctx, opts)
- if err != nil {
- ctx.ServerError("FindTasks", err)
- return
- }
- if err = tasks.LoadAttributes(ctx); err != nil {
+ if err = actions_model.TaskList(tasks).LoadAttributes(ctx); err != nil {
ctx.ServerError("TasksLoadAttributes", err)
return
}