feat: add task to cleanup the ActionUser table weekly

test coverage is provided by TestAPICron which runs
registerCleanupActionUser()
This commit is contained in:
Earl Warren 2025-10-30 16:13:04 +01:00
parent 917d0e9fa0
commit e41bcf5048
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 13 additions and 2 deletions

View file

@ -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)
})
}

View file

@ -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) {