fix: ограничить статистику 7 днями и убрать 30d из дашборда
This commit is contained in:
+12
-13
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user