From 81748abce43df5522c3cdf5554bd3401a247ac14 Mon Sep 17 00:00:00 2001 From: Chang lue Tsen Date: Mon, 20 Oct 2025 10:18:07 -0400 Subject: [PATCH] fix(traffic_log): update deletion condition to use timestamp instead of created_at --- queue/logic/traffic/trafficStatLogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queue/logic/traffic/trafficStatLogic.go b/queue/logic/traffic/trafficStatLogic.go index 81a422b..e5357a8 100644 --- a/queue/logic/traffic/trafficStatLogic.go +++ b/queue/logic/traffic/trafficStatLogic.go @@ -167,7 +167,7 @@ func (l *StatLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error { // Delete old traffic logs 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 { logger.Errorf("[Traffic Stat Queue] Delete server traffic log failed: %v", err.Error()) }