new-api/service/channel_monitor_cleanup.go
zizi 959ee42bcb feat: add channel monitor rollups
Aggregate monitor history into daily rollups and add maintenance helpers for rollup refresh and history cleanup.
2026-05-20 13:51:22 +08:00

18 lines
397 B
Go

package service
import (
"errors"
"time"
"github.com/QuantumNous/new-api/model"
)
const ChannelMonitorHistoryRetention = 7 * 24 * time.Hour
func CleanOldChannelMonitorHistory(retention time.Duration, now time.Time) (int64, error) {
if retention <= 0 {
return 0, errors.New("history retention must be positive")
}
return model.DeleteChannelMonitorHistoriesBefore(now.Add(-retention))
}