fix: ограничить статистику 7 днями и убрать 30d из дашборда
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const hysteriaVersionCacheTTL = 15 * time.Minute
|
||||
const statsRetention = 7 * 24 * time.Hour
|
||||
|
||||
var ansiRe = regexp.MustCompile(`\x1b\[[0-9;]*[A-Za-z]`)
|
||||
var hysteriaVersionRe = regexp.MustCompile(`(?i)v?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?`)
|
||||
@@ -150,9 +151,19 @@ func CollectMetricsSnapshot() {
|
||||
_ = dao.SaveMetricSample(metric)
|
||||
}
|
||||
|
||||
func CleanupMetricsRetention() {
|
||||
cutoff := time.Now().Add(-72 * time.Hour).UnixMilli()
|
||||
_ = dao.CleanupMetricSample(cutoff)
|
||||
func CleanupStatsRetention() {
|
||||
now := time.Now()
|
||||
cutoffMs := now.Add(-statsRetention).UnixMilli()
|
||||
|
||||
hourMs := int64(time.Hour / time.Millisecond)
|
||||
dayMs := int64(24 * time.Hour / time.Millisecond)
|
||||
cutoffHour := cutoffMs - (cutoffMs % hourMs)
|
||||
cutoffDay := cutoffMs - (cutoffMs % dayMs)
|
||||
|
||||
_ = dao.CleanupMetricSample(cutoffMs)
|
||||
_ = dao.CleanupTrafficSample(cutoffMs)
|
||||
_ = dao.CleanupTrafficAggregateHourly(cutoffHour)
|
||||
_ = dao.CleanupTrafficAggregateDaily(cutoffDay)
|
||||
}
|
||||
|
||||
func DashboardSnapshot() metricsSnapshot {
|
||||
|
||||
Reference in New Issue
Block a user