From 9ea5b3f87a6352160fdbdc107e1e8566e5a3106f Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 4 Oct 2022 08:55:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=B8=A6=E5=AE=BD=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=92=8C=E7=BB=93=E6=9D=9F=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/server_bandwidth_stat_dao.go | 4 ++++ internal/db/models/user_bandwidth_stat_dao.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/internal/db/models/server_bandwidth_stat_dao.go b/internal/db/models/server_bandwidth_stat_dao.go index cb1b3aef..4df3cb1f 100644 --- a/internal/db/models/server_bandwidth_stat_dao.go +++ b/internal/db/models/server_bandwidth_stat_dao.go @@ -396,6 +396,10 @@ func (this *ServerBandwidthStatDAO) FindMonthlyPercentile(tx *dbs.Tx, serverId i // FindPercentileBetweenDays 获取日期段内内百分位 func (this *ServerBandwidthStatDAO) FindPercentileBetweenDays(tx *dbs.Tx, serverId int64, dayFrom string, dayTo string, percentile int32) (result *ServerBandwidthStat, err error) { + if dayFrom > dayTo { + dayFrom, dayTo = dayTo, dayFrom + } + if percentile <= 0 { percentile = 95 } diff --git a/internal/db/models/user_bandwidth_stat_dao.go b/internal/db/models/user_bandwidth_stat_dao.go index 596e31a4..692ecd0c 100644 --- a/internal/db/models/user_bandwidth_stat_dao.go +++ b/internal/db/models/user_bandwidth_stat_dao.go @@ -96,6 +96,10 @@ func (this *UserBandwidthStatDAO) FindUserPeekBandwidthInMonth(tx *dbs.Tx, userI // FindPercentileBetweenDays 获取日期段内内百分位 func (this *UserBandwidthStatDAO) FindPercentileBetweenDays(tx *dbs.Tx, userId int64, dayFrom string, dayTo string, percentile int32) (result *UserBandwidthStat, err error) { + if dayFrom > dayTo { + dayFrom, dayTo = dayTo, dayFrom + } + if percentile <= 0 { percentile = 95 }