fix: корректная агрегация top peers по диапазонам и починка hourly bucket
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user