Compare commits

...

3 Commits

Author SHA1 Message Date
刘祥超
c66e28cb9d 减少带宽统计显示的空档期 2022-09-05 16:04:34 +08:00
刘祥超
e5109b24d4 版本修改为0.5.2.1 2022-09-05 16:02:55 +08:00
刘祥超
695b8482de 将版本修改为0.5.3 2022-09-05 11:03:12 +08:00
4 changed files with 20 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
package teaconst package teaconst
const ( const (
Version = "0.5.2" Version = "0.5.2.1"
ProductName = "Edge API" ProductName = "Edge API"
ProcessName = "edge-api" ProcessName = "edge-api"
@@ -20,9 +20,9 @@ const (
NodeVersion = "0.5.2" NodeVersion = "0.5.2"
UserNodeVersion = "0.4.1" UserNodeVersion = "0.4.1"
DNSNodeVersion = "0.2.6"
AuthorityNodeVersion = "0.0.2" AuthorityNodeVersion = "0.0.2"
MonitorNodeVersion = "0.0.4" MonitorNodeVersion = "0.0.4"
DNSNodeVersion = "0.2.6"
ReportNodeVersion = "0.1.1" ReportNodeVersion = "0.1.1"
// SQLVersion SQL版本号 // SQLVersion SQL版本号

View File

@@ -862,20 +862,21 @@ func (this *ServerDAO) ListEnabledServersMatch(tx *dbs.Tx, offset int64, size in
} }
// 排序 // 排序
var timestamp = time.Now().Unix() / 300 * 300 var timestamp = (time.Now().Unix()) / 300 * 300
var currentTime = timeutil.FormatTime("YmdHi", timestamp) var times = []string{
var prevTime = timeutil.FormatTime("YmdHi", timestamp-300) timeutil.FormatTime("YmdHi", timestamp),
timeutil.FormatTime("YmdHi", timestamp-300),
timeutil.FormatTime("YmdHi", timestamp-300*2),
}
switch order { switch order {
case "trafficOutAsc": case "trafficOutAsc":
query.Asc("IF(IF(bandwidthTime=:currentTime, bandwidthBytes, 0) > 0, IF(bandwidthTime=:currentTime, bandwidthBytes, 0), IF(bandwidthTime=:prevTime, bandwidthBytes, 0))") query.Asc("IF(FIND_IN_SET(bandwidthTime, :times), bandwidthBytes, 0)")
query.Param("currentTime", currentTime) query.Param("times", strings.Join(times, ","))
query.Param("prevTime", prevTime)
query.DescPk() query.DescPk()
case "trafficOutDesc": case "trafficOutDesc":
query.Desc("IF(IF(bandwidthTime=:currentTime, bandwidthBytes, 0) > 0, IF(bandwidthTime=:currentTime, bandwidthBytes, 0), IF(bandwidthTime=:prevTime, bandwidthBytes, 0))") query.Desc("IF(FIND_IN_SET(bandwidthTime, :times), bandwidthBytes, 0)")
query.Param("currentTime", currentTime) query.Param("times", strings.Join(times, ","))
query.Param("prevTime", prevTime)
query.DescPk() query.DescPk()
default: default:
query.DescPk() query.DescPk()
@@ -885,7 +886,7 @@ func (this *ServerDAO) ListEnabledServersMatch(tx *dbs.Tx, offset int64, size in
// 修正带宽统计数据 // 修正带宽统计数据
for _, server := range result { for _, server := range result {
if len(server.BandwidthTime) > 0 && server.BandwidthBytes > 0 && server.BandwidthTime < prevTime { if len(server.BandwidthTime) > 0 && !lists.ContainsString(times, server.BandwidthTime) {
server.BandwidthBytes = 0 server.BandwidthBytes = 0
} }
} }

View File

@@ -9,7 +9,6 @@ import (
"github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types" "github.com/iwind/TeaGo/types"
"sync" "sync"
@@ -20,10 +19,7 @@ var serverBandwidthStatsMap = map[string]*pb.ServerBandwidthStat{} // key => ban
var serverBandwidthStatsLocker = &sync.Mutex{} var serverBandwidthStatsLocker = &sync.Mutex{}
func init() { func init() {
var ticker = time.NewTicker(5 * time.Minute) var ticker = time.NewTicker(1 * time.Minute)
if Tea.IsTesting() {
ticker = time.NewTicker(1 * time.Minute)
}
dbs.OnReadyDone(func() { dbs.OnReadyDone(func() {
goman.New(func() { goman.New(func() {

View File

@@ -415,11 +415,13 @@ func (this *ServerStatBoardService) ComposeServerStatBoard(ctx context.Context,
// 当前N分钟区间 // 当前N分钟区间
{ {
// 查询最近的个时段,以尽可能获取数据 // 查询最近的个时段,以尽可能获取数据
var minute1 = timeutil.FormatTime("Hi", time.Now().Unix()/300*300) var timestamp = time.Now().Unix() / 300 * 300
var minute2 = timeutil.FormatTime("Hi", time.Now().Unix()/300*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) bytes, err := models.SharedServerBandwidthStatDAO.FindMinutelyPeekBandwidthBytes(tx, req.ServerId, day, minute)
if err != nil { if err != nil {
return nil, err return nil, err