refactor: ddns (#414)

* refactor ddns

* update webhook
This commit is contained in:
UUBulb
2024-08-24 11:11:06 +08:00
committed by GitHub
parent 64da3c7438
commit eb6dd2855e
17 changed files with 523 additions and 352 deletions

View File

@@ -1,6 +1,7 @@
package model
import (
"slices"
"strings"
"time"
@@ -44,19 +45,6 @@ func percentage(used, total uint64) float64 {
return float64(used) * 100 / float64(total)
}
func maxSliceValue(slice []float64) float64 {
if len(slice) != 0 {
max := slice[0]
for _, val := range slice {
if max < val {
max = val
}
}
return max
}
return 0
}
// Snapshot 未通过规则返回 struct{}{}, 通过返回 nil
func (u *Rule) Snapshot(cycleTransferStats *CycleTransferStats, server *Server, db *gorm.DB) interface{} {
// 监控全部但是排除了此服务器
@@ -145,7 +133,7 @@ func (u *Rule) Snapshot(cycleTransferStats *CycleTransferStats, server *Server,
temp = append(temp, tempStat.Temperature)
}
}
src = maxSliceValue(temp)
src = slices.Max(temp)
}
}