From 7f6a803d245fd848276ad85d0127cb1ff51263ca Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 4 Jan 2023 16:16:31 +0800 Subject: [PATCH] fix: omit total in FindTasks --- models/actions/task_list.go | 5 ++--- routers/web/shared/actions/runners.go | 2 +- services/actions/actions.go | 2 +- services/actions/clear_tasks.go | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/models/actions/task_list.go b/models/actions/task_list.go index aab87edd57..1f6b16772b 100644 --- a/models/actions/task_list.go +++ b/models/actions/task_list.go @@ -88,7 +88,7 @@ func (opts FindTaskOptions) toConds() builder.Cond { return cond } -func FindTasks(ctx context.Context, opts FindTaskOptions) (TaskList, int64, error) { +func FindTasks(ctx context.Context, opts FindTaskOptions) (TaskList, error) { e := db.GetEngine(ctx).Where(opts.toConds()) if opts.PageSize > 0 && opts.Page >= 1 { e.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) @@ -97,8 +97,7 @@ func FindTasks(ctx context.Context, opts FindTaskOptions) (TaskList, int64, erro e.OrderBy("id DESC") } var tasks TaskList - total, err := e.FindAndCount(&tasks) - return tasks, total, err + return tasks, e.Find(&tasks) } func CountTasks(ctx context.Context, opts FindTaskOptions) (int64, error) { diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go index 7cf1db5d76..6f6f518ba4 100644 --- a/routers/web/shared/actions/runners.go +++ b/routers/web/shared/actions/runners.go @@ -98,7 +98,7 @@ func RunnerDetails(ctx *context.Context, tplName base.TplName, page int, runnerI return } - tasks, _, err := actions_model.FindTasks(ctx, opts) + tasks, err := actions_model.FindTasks(ctx, opts) if err != nil { ctx.ServerError("FindTasks", err) return diff --git a/services/actions/actions.go b/services/actions/actions.go index 1a0ed4b55e..f415ae3824 100644 --- a/services/actions/actions.go +++ b/services/actions/actions.go @@ -34,7 +34,7 @@ func Init() { } func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository) error { - tasks, _, err := actions_model.FindTasks(ctx, actions_model.FindTaskOptions{RepoID: repo.ID}) + tasks, err := actions_model.FindTasks(ctx, actions_model.FindTaskOptions{RepoID: repo.ID}) if err != nil { return fmt.Errorf("find task of repo %v: %w", repo.ID, err) } diff --git a/services/actions/clear_tasks.go b/services/actions/clear_tasks.go index 26c6170657..1064c2a2e2 100644 --- a/services/actions/clear_tasks.go +++ b/services/actions/clear_tasks.go @@ -38,7 +38,7 @@ func StopEndlessTasks(ctx context.Context) error { } func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error { - tasks, _, err := actions_model.FindTasks(ctx, opts) + tasks, err := actions_model.FindTasks(ctx, opts) if err != nil { return fmt.Errorf("find tasks: %w", err) }