mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-13 06:20:24 +00:00
feat: add task to cleanup the ActionUser table weekly
test coverage is provided by TestAPICron which runs registerCleanupActionUser()
This commit is contained in:
parent
917d0e9fa0
commit
e41bcf5048
2 changed files with 13 additions and 2 deletions
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue