diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-11-24 11:49:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-24 03:49:41 +0000 |
commit | df1e7d0067bb39913eb681ccc920649884fb1938 (patch) | |
tree | 2419feab5c28658adb7f71878df646bdc9bdc50e /models/actions/run.go | |
parent | d24a8223ce1e47a0c9b103aae07f67c3112ca048 (diff) | |
download | gitea-df1e7d0067bb39913eb681ccc920649884fb1938.tar.gz gitea-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 'models/actions/run.go')
-rw-r--r-- | models/actions/run.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/models/actions/run.go b/models/actions/run.go index 8078613fb8..4656aa22a2 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -170,7 +170,7 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err // CancelRunningJobs cancels all running and waiting jobs associated with a specific workflow. func CancelRunningJobs(ctx context.Context, repoID int64, ref, workflowID string) error { // Find all runs in the specified repository, reference, and workflow with statuses 'Running' or 'Waiting'. - runs, total, err := FindRuns(ctx, FindRunOptions{ + runs, total, err := db.FindAndCount[ActionRun](ctx, FindRunOptions{ RepoID: repoID, Ref: ref, WorkflowID: workflowID, @@ -188,7 +188,7 @@ func CancelRunningJobs(ctx context.Context, repoID int64, ref, workflowID string // Iterate over each found run and cancel its associated jobs. for _, run := range runs { // Find all jobs associated with the current run. - jobs, _, err := FindRunJobs(ctx, FindRunJobOptions{ + jobs, err := db.Find[ActionRunJob](ctx, FindRunJobOptions{ RunID: run.ID, }) if err != nil { |