提供按小时、按天查询带宽峰值的API

This commit is contained in:
刘祥超
2022-08-28 15:56:16 +08:00
parent 1b36bad60a
commit 896e54ebe8
3 changed files with 162 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/rands"
timeutil "github.com/iwind/TeaGo/utils/time"
"testing"
@@ -77,3 +78,24 @@ func TestServerBandwidthStatDAO_Clean(t *testing.T) {
}
t.Log("ok", time.Since(before).Seconds()*1000, "ms")
}
func TestServerBandwidthStatDAO_FindHourlyBandwidthStats(t *testing.T) {
var dao = models.NewServerBandwidthStatDAO()
var tx *dbs.Tx
stats, err := dao.FindHourlyBandwidthStats(tx, 23, 24)
if err != nil {
t.Fatal(err)
}
logs.PrintAsJSON(stats, t)
}
func TestServerBandwidthStatDAO_FindDailyBandwidthStats(t *testing.T) {
var dao = models.NewServerBandwidthStatDAO()
var tx *dbs.Tx
stats, err := dao.FindDailyBandwidthStats(tx, 23, 14)
if err != nil {
t.Fatal(err)
}
logs.PrintAsJSON(stats, t)
}