fix: корректная агрегация top peers по диапазонам и починка hourly bucket

This commit is contained in:
2026-05-09 21:31:03 +05:00
parent b6c86009e6
commit 1db7f24d5c
4 changed files with 42 additions and 14 deletions
+16 -2
View File
@@ -90,11 +90,25 @@ func DashboardTimeseries(rangeKey string) (vo.DashboardTimeseriesVo, error) {
func DashboardTopPeers(rangeKey string, limit int) ([]vo.DashboardTopPeerVo, error) {
nowMs := time.Now().UnixMilli()
normalizedRange := strings.TrimSpace(strings.ToLower(rangeKey))
fromMs := nowMs - int64(24*time.Hour/time.Millisecond)
if strings.TrimSpace(rangeKey) == "7d" {
source := "sample"
switch normalizedRange {
case "1h":
fromMs = nowMs - int64(time.Hour/time.Millisecond)
source = "sample"
case "7d":
fromMs = nowMs - int64(7*24*time.Hour/time.Millisecond)
source = "hourly"
case "24h", "":
fromMs = nowMs - int64(24*time.Hour/time.Millisecond)
source = "sample"
default:
fromMs = nowMs - int64(24*time.Hour/time.Millisecond)
source = "sample"
}
return dao.DashboardTopPeers(fromMs, nowMs, limit)
return dao.DashboardTopPeers(fromMs, nowMs, limit, source)
}
func DashboardSecurity() ([]vo.SecurityRiskVo, error) {