mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-30 21:10:28 +08:00
减少带宽统计显示的空档期
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/goman"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"sync"
|
||||
@@ -20,10 +19,7 @@ var serverBandwidthStatsMap = map[string]*pb.ServerBandwidthStat{} // key => ban
|
||||
var serverBandwidthStatsLocker = &sync.Mutex{}
|
||||
|
||||
func init() {
|
||||
var ticker = time.NewTicker(5 * time.Minute)
|
||||
if Tea.IsTesting() {
|
||||
ticker = time.NewTicker(1 * time.Minute)
|
||||
}
|
||||
var ticker = time.NewTicker(1 * time.Minute)
|
||||
|
||||
dbs.OnReadyDone(func() {
|
||||
goman.New(func() {
|
||||
|
||||
@@ -415,11 +415,13 @@ func (this *ServerStatBoardService) ComposeServerStatBoard(ctx context.Context,
|
||||
|
||||
// 当前N分钟区间
|
||||
{
|
||||
// 查询最近的两个时段,以尽可能获取数据
|
||||
var minute1 = timeutil.FormatTime("Hi", time.Now().Unix()/300*300)
|
||||
var minute2 = timeutil.FormatTime("Hi", time.Now().Unix()/300*300-300)
|
||||
// 查询最近的三个时段,以尽可能获取数据
|
||||
var timestamp = time.Now().Unix() / 300 * 300
|
||||
var minute1 = timeutil.FormatTime("Hi", timestamp)
|
||||
var minute2 = timeutil.FormatTime("Hi", timestamp-300)
|
||||
var minute3 = timeutil.FormatTime("Hi", timestamp-300*2)
|
||||
|
||||
for _, minute := range []string{minute1, minute2} {
|
||||
for _, minute := range []string{minute1, minute2, minute3} {
|
||||
bytes, err := models.SharedServerBandwidthStatDAO.FindMinutelyPeekBandwidthBytes(tx, req.ServerId, day, minute)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user