Aggregate monitor history into daily rollups and add maintenance helpers for rollup refresh and history cleanup.
18 lines
397 B
Go
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))
|
|
}
|