feat: 统计页支持一年时段和按日趋势

在线人数在新的有效访问后尽快刷新,历史查询保留一年并画出每日连接数。
This commit is contained in:
nixevol
2026-09-28 11:08:28 +08:00
parent 28170a7fe2
commit fe24a88bac
12 changed files with 358 additions and 36 deletions
+3 -3
View File
@@ -38,8 +38,8 @@ func TestParseRange(t *testing.T) {
}
})
t.Run("too long", func(t *testing.T) {
_, _, err := parseRange(now.Add(-73*time.Hour).Format(time.RFC3339), now.Format(time.RFC3339), now)
if err == nil || err.Code != "range_too_long" || err.Message != "时段不能超过 72 小时" {
_, _, err := parseRange(now.Add(-retainDuration-time.Hour).Format(time.RFC3339), now.Format(time.RFC3339), now)
if err == nil || err.Code != "range_too_long" || err.Message != "时段不能超过 1 年" {
t.Fatalf("%+v", err)
}
})
@@ -127,7 +127,7 @@ func TestRangeHTTP(t *testing.T) {
}
q := url.Values{}
q.Set("start", now.Add(-73*time.Hour).Format(time.RFC3339))
q.Set("start", now.Add(-retainDuration-time.Hour).Format(time.RFC3339))
q.Set("end", now.Format(time.RFC3339))
rr = call(q.Encode())
if rr.Code != 400 || decodeErr(rr).Error != "range_too_long" {