chore(server): domain_events 清理周期从 90 天缩短为 7 天
This commit is contained in:
@@ -3,7 +3,7 @@ use std::time::Duration;
|
|||||||
/// 启动事件清理后台任务。
|
/// 启动事件清理后台任务。
|
||||||
///
|
///
|
||||||
/// 每日执行一次:
|
/// 每日执行一次:
|
||||||
/// - 调用 `cleanup_old_published_events()` 归档 >90 天的已发布事件
|
/// - 调用 `cleanup_old_published_events()` 归档 >7 天的已发布事件
|
||||||
/// - 调用 `cleanup_old_processed_events()` 清理 >7 天的去重记录
|
/// - 调用 `cleanup_old_processed_events()` 清理 >7 天的去重记录
|
||||||
pub fn start_event_cleanup(db: sea_orm::DatabaseConnection) {
|
pub fn start_event_cleanup(db: sea_orm::DatabaseConnection) {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
@@ -21,9 +21,9 @@ pub fn start_event_cleanup(db: sea_orm::DatabaseConnection) {
|
|||||||
async fn run_cleanup(db: &sea_orm::DatabaseConnection) -> Result<(), sea_orm::DbErr> {
|
async fn run_cleanup(db: &sea_orm::DatabaseConnection) -> Result<(), sea_orm::DbErr> {
|
||||||
use sea_orm::ConnectionTrait;
|
use sea_orm::ConnectionTrait;
|
||||||
|
|
||||||
// 归档 >90 天的已发布事件
|
// 归档 >7 天的已发布事件
|
||||||
match db
|
match db
|
||||||
.execute_unprepared("SELECT cleanup_old_published_events(90, 1000)")
|
.execute_unprepared("SELECT cleanup_old_published_events(7, 1000)")
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user