fix: ограничить статистику 7 днями и убрать 30d из дашборда
This commit is contained in:
@@ -67,3 +67,36 @@ func UpsertTrafficAggregateDaily(peerId int64, dayStart int64, rxBytes int64, tx
|
||||
func gormExprAdd(column string, delta int64) interface{} {
|
||||
return gorm.Expr(fmt.Sprintf("%s + ?", column), delta)
|
||||
}
|
||||
|
||||
func CleanupTrafficSample(olderThanMs int64) error {
|
||||
if !tableExists("traffic_sample") {
|
||||
return nil
|
||||
}
|
||||
if tx := sqliteDB.Exec("DELETE FROM traffic_sample WHERE sampled_at < ?", olderThanMs); tx.Error != nil {
|
||||
logrus.Errorf("%v", tx.Error)
|
||||
return errors.New(constant.SysError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CleanupTrafficAggregateHourly(olderThanMs int64) error {
|
||||
if !tableExists("traffic_aggregate_hourly") {
|
||||
return nil
|
||||
}
|
||||
if tx := sqliteDB.Exec("DELETE FROM traffic_aggregate_hourly WHERE hour_start < ?", olderThanMs); tx.Error != nil {
|
||||
logrus.Errorf("%v", tx.Error)
|
||||
return errors.New(constant.SysError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CleanupTrafficAggregateDaily(olderThanMs int64) error {
|
||||
if !tableExists("traffic_aggregate_daily") {
|
||||
return nil
|
||||
}
|
||||
if tx := sqliteDB.Exec("DELETE FROM traffic_aggregate_daily WHERE day_start < ?", olderThanMs); tx.Error != nil {
|
||||
logrus.Errorf("%v", tx.Error)
|
||||
return errors.New(constant.SysError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user