统计带宽计算增加最小样本数

This commit is contained in:
GoEdgeLab
2023-09-06 18:14:08 +08:00
parent 973046044d
commit 81d5cf5ebe

View File

@@ -380,7 +380,7 @@ func (this *ServerBandwidthStatDAO) FindAllServerStatsWithMonth(tx *dbs.Tx, serv
} }
// FindMonthlyPercentile 获取某月内百分位 // FindMonthlyPercentile 获取某月内百分位
func (this *ServerBandwidthStatDAO) FindMonthlyPercentile(tx *dbs.Tx, serverId int64, month string, percentile int, useAvg bool, noPlan bool) (result int64, err error) { func (this *ServerBandwidthStatDAO) FindMonthlyPercentile(tx *dbs.Tx, serverId int64, month string, percentile int, useAvg bool, noPlan bool, minSamples int) (result int64, err error) {
if percentile <= 0 { if percentile <= 0 {
percentile = 95 percentile = 95
} }
@@ -415,7 +415,7 @@ func (this *ServerBandwidthStatDAO) FindMonthlyPercentile(tx *dbs.Tx, serverId i
if err != nil { if err != nil {
return 0, err return 0, err
} }
if total == 0 { if total == 0 || total < int64(minSamples) {
return 0, nil return 0, nil
} }