From 42a76b578d70bb6da355c7e3cfe20dd2dd727844 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 23 Mar 2023 11:23:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=8D=E5=8A=A1=E5=B8=A6?= =?UTF-8?q?=E5=AE=BD=E6=9F=A5=E8=AF=A2=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/server_bandwidth_stat_dao.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/db/models/server_bandwidth_stat_dao.go b/internal/db/models/server_bandwidth_stat_dao.go index eda99998..f0cc52f8 100644 --- a/internal/db/models/server_bandwidth_stat_dao.go +++ b/internal/db/models/server_bandwidth_stat_dao.go @@ -127,6 +127,7 @@ func (this *ServerBandwidthStatDAO) FindHourlyBandwidthStats(tx *dbs.Tx, serverI ones, _, err := this.Query(tx). Table(this.partialTable(serverId)). + Between("day", timeutil.FormatTime("Ymd", timestamp), timeutil.Format("Ymd")). Attr("serverId", serverId). Result(this.maxBytesField(useAvg), "CONCAT(day, '.', SUBSTRING(timeAt, 1, 2)) AS fullTime"). Gte("CONCAT(day, '.', SUBSTRING(timeAt, 1, 2))", timeutil.FormatTime("Ymd.H", timestamp)). @@ -526,6 +527,7 @@ func (this *ServerBandwidthStatDAO) FindPercentileBetweenTimes(tx *dbs.Tx, serve // 总数量 total, err := this.Query(tx). Table(this.partialTable(serverId)). + Between("day", timeFrom[:8], timeTo[:8]). Attr("serverId", serverId). Between("CONCAT(day, timeAt)", timeFrom, timeTo). Count() @@ -545,6 +547,7 @@ func (this *ServerBandwidthStatDAO) FindPercentileBetweenTimes(tx *dbs.Tx, serve // 查询 nth 位置 one, err := this.Query(tx). Table(this.partialTable(serverId)). + Between("day", timeFrom[:8], timeTo[:8]). Attr("serverId", serverId). Between("CONCAT(day, timeAt)", timeFrom, timeTo). Desc(this.bytesOrderField(useAvg)). @@ -635,6 +638,7 @@ func (this *ServerBandwidthStatDAO) FindHourlyStats(tx *dbs.Tx, serverId int64, var query = this.Query(tx). Table(this.partialTable(serverId)). + Between("day", hourFrom[:8], hourTo[:8]). Result("MIN(day) AS day", "MIN(timeAt) AS timeAt", "SUM(totalBytes) AS totalBytes", "SUM(cachedBytes) AS cachedBytes", "SUM(countRequests) AS countRequests", "SUM(countCachedRequests) AS countCachedRequests", "SUM(countAttackRequests) AS countAttackRequests", "SUM(attackBytes) AS attackBytes", "CONCAT(day, SUBSTR(timeAt, 1, 2)) AS hour"). Attr("serverId", serverId)