summaryrefslogtreecommitdiffstats
path: root/modules/cron
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2021-05-01 20:17:02 +0800
committerGitHub <noreply@github.com>2021-05-01 14:17:02 +0200
commitae6d7860be6a5f5032f86369af3adcedf0ad0725 (patch)
treef11369529ab4bf4c0dd73500ec4470320dd4cf6e /modules/cron
parentca0460beb7201737510f522c1aa6d1cc7f394f72 (diff)
downloadgitea-ae6d7860be6a5f5032f86369af3adcedf0ad0725.tar.gz
gitea-ae6d7860be6a5f5032f86369af3adcedf0ad0725.zip
add cron job to delete old actions from database (#15688)
that's a way to save database storage space. Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'modules/cron')
-rw-r--r--modules/cron/tasks_extended.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/cron/tasks_extended.go b/modules/cron/tasks_extended.go
index f0742eb471..4a37e5d242 100644
--- a/modules/cron/tasks_extended.go
+++ b/modules/cron/tasks_extended.go
@@ -117,6 +117,20 @@ func registerRemoveRandomAvatars() {
})
}
+func registerDeleteOldActions() {
+ RegisterTaskFatal("delete_old_actions", &OlderThanConfig{
+ BaseConfig: BaseConfig{
+ Enabled: false,
+ RunAtStart: false,
+ Schedule: "@every 168h",
+ },
+ OlderThan: 365 * 24 * time.Hour,
+ }, func(ctx context.Context, _ *models.User, config Config) error {
+ olderThanConfig := config.(*OlderThanConfig)
+ return models.DeleteOldActions(olderThanConfig.OlderThan)
+ })
+}
+
func initExtendedTasks() {
registerDeleteInactiveUsers()
registerDeleteRepositoryArchives()
@@ -127,4 +141,5 @@ func initExtendedTasks() {
registerReinitMissingRepositories()
registerDeleteMissingRepositories()
registerRemoveRandomAvatars()
+ registerDeleteOldActions()
}