From e41bcf5048efaa36d19f21d67e37377e0f77c422 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 30 Oct 2025 16:13:04 +0100 Subject: [PATCH] feat: add task to cleanup the ActionUser table weekly test coverage is provided by TestAPICron which runs registerCleanupActionUser() --- services/cron/tasks_actions.go | 11 +++++++++++ tests/integration/api_admin_test.go | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/services/cron/tasks_actions.go b/services/cron/tasks_actions.go index 2cd484fa69..25c16bdd8d 100644 --- a/services/cron/tasks_actions.go +++ b/services/cron/tasks_actions.go @@ -22,6 +22,7 @@ func initActionsTasks() { registerScheduleTasks() registerActionsCleanup() registerOfflineRunnersCleanup() + registerCleanupActionUser() } func registerStopZombieTasks() { @@ -95,3 +96,13 @@ func registerOfflineRunnersCleanup() { ) }) } + +func registerCleanupActionUser() { + RegisterTaskFatal("actions_action_user", &BaseConfig{ + Enabled: true, + RunAtStart: true, + Schedule: "@weekly", + }, func(ctx context.Context, _ *user_model.User, _ Config) error { + return actions_service.CleanupActionUser(ctx) + }) +} diff --git a/tests/integration/api_admin_test.go b/tests/integration/api_admin_test.go index 7f91ac3874..ce63cf259c 100644 --- a/tests/integration/api_admin_test.go +++ b/tests/integration/api_admin_test.go @@ -357,11 +357,11 @@ func TestAPICron(t *testing.T) { AddTokenAuth(token) resp := MakeRequest(t, req, http.StatusOK) - assert.Equal(t, "29", resp.Header().Get("X-Total-Count")) + assert.Equal(t, "30", resp.Header().Get("X-Total-Count")) var crons []api.Cron DecodeJSON(t, resp, &crons) - assert.Len(t, crons, 29) + assert.Len(t, crons, 30) }) t.Run("Execute", func(t *testing.T) {