mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-05 01:20:25 +08:00
节点统计数据只保留两个小时
This commit is contained in:
@@ -57,12 +57,10 @@ func (this *NodeValueDAO) CreateValue(tx *dbs.Tx, clusterId int64, role nodeconf
|
||||
|
||||
// Clean 清除数据
|
||||
func (this *NodeValueDAO) Clean(tx *dbs.Tx) error {
|
||||
// 删除N天之前的所有数据
|
||||
expiredDays := 2
|
||||
day := timeutil.Format("Ymd", time.Now().AddDate(0, 0, -expiredDays))
|
||||
var hour = timeutil.Format("YmdH", time.Now().Add(-2*time.Hour))
|
||||
_, err := this.Query(tx).
|
||||
Where("day<=:day").
|
||||
Param("day", day).
|
||||
Where("hour<=:hour").
|
||||
Param("hour", hour).
|
||||
Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNodeValueDAO_CreateValue(t *testing.T) {
|
||||
dao := NewNodeValueDAO()
|
||||
var dao = NewNodeValueDAO()
|
||||
m := maps.Map{
|
||||
"hello": "world12344",
|
||||
}
|
||||
@@ -20,3 +20,12 @@ func TestNodeValueDAO_CreateValue(t *testing.T) {
|
||||
}
|
||||
t.Log("ok")
|
||||
}
|
||||
|
||||
func TestNodeValueDAO_Clean(t *testing.T) {
|
||||
var dao = NewNodeValueDAO()
|
||||
err := dao.Clean(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("ok")
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -29,7 +29,7 @@ func NewMonitorItemValueTask() *MonitorItemValueTask {
|
||||
}
|
||||
|
||||
func (this *MonitorItemValueTask) Start() {
|
||||
ticker := time.NewTicker(24 * time.Hour)
|
||||
ticker := time.NewTicker(1 * time.Hour)
|
||||
if Tea.IsTesting() {
|
||||
ticker = time.NewTicker(1 * time.Minute)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user