mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-02 17:20:53 +02:00
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>
This commit is contained in:
1 parent
ca0460beb7
commit
ae6d7860be
5 files changed
+42
No files matched your search
@@ -395,3 +395,13 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
|
||||
|
||||
return cond, nil
|
||||
}
|
||||
|
||||
// DeleteOldActions deletes all old actions from database.
|
||||
func DeleteOldActions(olderThan time.Duration) (err error) {
|
||||
if olderThan <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err = x.Where("created_unix < ?", time.Now().Add(-olderThan).Unix()).Delete(&Action{})
|
||||
return
|
||||
}
|
||||
Reference in new issue
Block a user