fix: ограничить статистику 7 днями и убрать 30d из дашборда

This commit is contained in:
2026-05-09 16:07:54 +05:00
parent 78656e74b0
commit 44c01d39d0
6 changed files with 62 additions and 22 deletions
+12 -13
View File
@@ -46,28 +46,29 @@ func DashboardTimeseries(rangeKey string) (vo.DashboardTimeseriesVo, error) {
fromMs := nowMs - int64(24*time.Hour/time.Millisecond)
bucketMs := int64(5 * time.Minute / time.Millisecond)
source := "sample"
r := strings.TrimSpace(rangeKey)
if r == "1h" {
r := "24h"
switch strings.TrimSpace(rangeKey) {
case "1h":
fromMs = nowMs - int64(time.Hour/time.Millisecond)
bucketMs = int64(time.Minute / time.Millisecond)
source = "sample"
} else if r == "7d" {
r = "1h"
case "7d":
fromMs = nowMs - int64(7*24*time.Hour/time.Millisecond)
bucketMs = int64(time.Hour / time.Millisecond)
source = "hourly"
} else if r == "30d" {
fromMs = nowMs - int64(30*24*time.Hour/time.Millisecond)
bucketMs = int64(24 * time.Hour / time.Millisecond)
source = "daily"
r = "30d"
} else if r == "" {
r = "24h"
r = "7d"
case "24h", "":
fromMs = nowMs - int64(24*time.Hour/time.Millisecond)
bucketMs = int64(5 * time.Minute / time.Millisecond)
source = "sample"
} else {
r = "24h"
default:
fromMs = nowMs - int64(24*time.Hour/time.Millisecond)
bucketMs = int64(5 * time.Minute / time.Millisecond)
source = "sample"
r = "24h"
}
traffic, err := dao.DashboardTrafficTimeseries(fromMs, nowMs, bucketMs, source)
@@ -92,8 +93,6 @@ func DashboardTopPeers(rangeKey string, limit int) ([]vo.DashboardTopPeerVo, err
fromMs := nowMs - int64(24*time.Hour/time.Millisecond)
if strings.TrimSpace(rangeKey) == "7d" {
fromMs = nowMs - int64(7*24*time.Hour/time.Millisecond)
} else if strings.TrimSpace(rangeKey) == "30d" {
fromMs = nowMs - int64(30*24*time.Hour/time.Millisecond)
}
return dao.DashboardTopPeers(fromMs, nowMs, limit)
}