Modify alert function

This commit is contained in:
710leo 2020-12-31 15:11:59 +08:00
parent 6dbbbac344
commit c2867d9638
1 changed files with 0 additions and 60 deletions

View File

@ -24,11 +24,6 @@ func (f MaxFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonF
return
}
duration := int(vs[0].Timestamp - vs[count-1].Timestamp)
if duration < f.Limit {
return
}
max := vs[0].Value
for i := 1; i < len(vs); i++ {
if max < vs[i].Value {
@ -54,11 +49,6 @@ func (f MinFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonF
return
}
duration := int(vs[0].Timestamp - vs[count-1].Timestamp)
if duration < f.Limit {
return
}
min := vs[0].Value
for i := 1; i < len(vs); i++ {
@ -85,11 +75,6 @@ func (f AllFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonF
return
}
duration := int(vs[0].Timestamp - vs[count-1].Timestamp)
if duration < f.Limit {
return
}
for i := 0; i < len(vs); i++ {
isTriggered = checkIsTriggered(vs[i].Value, f.Operator, f.RightValue)
if !isTriggered {
@ -114,11 +99,6 @@ func (f SumFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonF
return
}
duration := int(vs[0].Timestamp - vs[count-1].Timestamp)
if duration < f.Limit {
return
}
sum := dataobj.JsonFloat(0.0)
for i := 0; i < count; i++ {
sum += vs[i].Value
@ -142,11 +122,6 @@ func (f AvgFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonF
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
sum := dataobj.JsonFloat(0.0)
for i := 0; i < vsLen; i++ {
@ -171,11 +146,6 @@ func (f StddevFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.Js
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
for i := 0; i < vsLen; i++ {
sum += float64(vs[i].Value)
}
@ -210,11 +180,6 @@ func (f DiffFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.Json
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
first := vs[0].Value
isTriggered = false
@ -244,11 +209,6 @@ func (f PDiffFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.Jso
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
first := vs[0].Value
isTriggered = false
for i := 1; i < len(vs); i++ {
@ -315,11 +275,6 @@ func (f CAvgAbsFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.J
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
sum := dataobj.JsonFloat(0.0)
for i := 0; i < vsLen; i++ {
@ -347,11 +302,6 @@ func (f CAvgFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.Json
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
sum := dataobj.JsonFloat(0.0)
for i := 0; i < vsLen; i++ {
sum += vs[i].Value
@ -377,11 +327,6 @@ func (f CAvgRateAbsFunction) Compute(vs []*dataobj.HistoryData) (leftValue datao
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
sum := dataobj.JsonFloat(0.0)
for i := 0; i < vsLen; i++ {
sum += vs[i].Value
@ -408,11 +353,6 @@ func (f CAvgRateFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.
return
}
duration := int(vs[0].Timestamp - vs[vsLen-1].Timestamp)
if duration < f.Limit {
return
}
sum := dataobj.JsonFloat(0.0)
for i := 0; i < vsLen; i++ {
sum += vs[i].Value