mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-06 23:45:47 +08:00
节点看板数据中增加当月、昨日、今日流量
This commit is contained in:
@@ -114,8 +114,8 @@ func (this *NodeClusterTrafficDailyStatDAO) FindDailyStats(tx *dbs.Tx, clusterId
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SumDailyStats 计算当月总流量
|
||||
func (this *NodeClusterTrafficDailyStatDAO) SumDailyStats(tx *dbs.Tx, clusterId int64, dayFrom string, dayTo string) (*NodeClusterTrafficDailyStat, error) {
|
||||
// SumDailyStat 计算当月总流量
|
||||
func (this *NodeClusterTrafficDailyStatDAO) SumDailyStat(tx *dbs.Tx, clusterId int64, dayFrom string, dayTo string) (*NodeClusterTrafficDailyStat, error) {
|
||||
one, err := this.Query(tx).
|
||||
Result("SUM(bytes) AS bytes", "SUM(cachedBytes) AS cachedBytes", "SUM(countRequests) AS countRequests", "SUM(countCachedRequests) AS countCachedRequests", "SUM(countAttackRequests) AS countAttackRequests", "SUM(attackBytes) AS attackBytes").
|
||||
Attr("clusterId", clusterId).
|
||||
|
||||
@@ -117,6 +117,21 @@ func (this *NodeTrafficDailyStatDAO) FindDailyStats(tx *dbs.Tx, role string, nod
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SumDailyStat 计算日期之间的总和
|
||||
func (this *NodeTrafficDailyStatDAO) SumDailyStat(tx *dbs.Tx, role string, nodeId int64, dayFrom string, dayTo string) (*NodeTrafficDailyStat, error) {
|
||||
one, err := this.Query(tx).
|
||||
Result("SUM(bytes) AS bytes", "SUM(cachedBytes) AS cachedBytes", "SUM(countRequests) AS countRequests", "SUM(countCachedRequests) AS countCachedRequests", "SUM(countAttackRequests) AS countAttackRequests", "SUM(attackBytes) AS attackBytes").
|
||||
Attr("nodeId", nodeId).
|
||||
Attr("role", role).
|
||||
Between("day", dayFrom, dayTo).
|
||||
Find()
|
||||
if err != nil || one == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return one.(*NodeTrafficDailyStat), nil
|
||||
}
|
||||
|
||||
// Clean 清理历史数据
|
||||
func (this *NodeTrafficDailyStatDAO) Clean(tx *dbs.Tx, days int) error {
|
||||
var day = timeutil.Format("Ymd", time.Now().AddDate(0, 0, -days))
|
||||
|
||||
Reference in New Issue
Block a user