fix(traffic_log): update deletion condition to use timestamp instead of created_at

This commit is contained in:
Chang lue Tsen 2025-10-20 10:18:07 -04:00
parent aa5e472184
commit 81748abce4

View File

@ -167,7 +167,7 @@ func (l *StatLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error {
// Delete old traffic logs // Delete old traffic logs
if l.svc.Config.Log.AutoClear { if l.svc.Config.Log.AutoClear {
err = tx.WithContext(ctx).Model(&traffic.TrafficLog{}).Where("created_at <= ?", end.AddDate(0, 0, int(-l.svc.Config.Log.ClearDays))).Delete(&traffic.TrafficLog{}).Error err = tx.WithContext(ctx).Model(&traffic.TrafficLog{}).Where("timestamp <= ?", end.AddDate(0, 0, int(-l.svc.Config.Log.ClearDays))).Delete(&traffic.TrafficLog{}).Error
if err != nil { if err != nil {
logger.Errorf("[Traffic Stat Queue] Delete server traffic log failed: %v", err.Error()) logger.Errorf("[Traffic Stat Queue] Delete server traffic log failed: %v", err.Error())
} }