优化数据统计

This commit is contained in:
GoEdgeLab
2023-07-30 14:49:16 +08:00
parent e6e3485acd
commit de2b0959b5
8 changed files with 61 additions and 8 deletions

View File

@@ -132,9 +132,10 @@ func (this *BandwidthStatManager) Loop() error {
for key, stat := range this.m {
if stat.Day < day || stat.TimeAt < currentTime {
// 防止数据出现错误
if stat.CachedBytes > stat.TotalBytes {
if stat.CachedBytes > stat.TotalBytes || stat.CountCachedRequests == stat.CountRequests {
stat.CachedBytes = stat.TotalBytes
}
if stat.AttackBytes > stat.TotalBytes {
stat.AttackBytes = stat.TotalBytes
}