bug fixes (#918)

* bug fixes

* fix for backward compatibility

* fix init

* cleanup

* possible fix

* optimize permission check

* Revert "possible fix"

This reverts commit 003f1bbb2aa368aade6702e6019922b7f4871a39.
This commit is contained in:
UUBulb
2024-12-26 23:38:40 +08:00
committed by GitHub
parent b876909a8a
commit 85818c2630
5 changed files with 16 additions and 10 deletions

View File

@@ -62,13 +62,9 @@ func (r *AlertRule) Enabled() bool {
}
// Snapshot 对传入的Server进行该报警规则下所有type的检查 返回每项检查结果
func (r *AlertRule) Snapshot(cycleTransferStats *CycleTransferStats, server *Server, db *gorm.DB, role uint8) []bool {
func (r *AlertRule) Snapshot(cycleTransferStats *CycleTransferStats, server *Server, db *gorm.DB) []bool {
point := make([]bool, len(r.Rules))
if r.UserID != server.UserID && role != RoleAdmin {
return point
}
for i, rule := range r.Rules {
point[i] = rule.Snapshot(cycleTransferStats, server, db)
}
@@ -85,8 +81,8 @@ func (r *AlertRule) Check(points [][]bool) (maxDuration int, passed bool) {
if maxDuration < 1 {
maxDuration = 1
}
for j := len(points[i]) - 1; j >= 0; j-- {
if !points[i][j] {
for j := len(points) - 1; j >= 0; j-- {
if !points[j][i] {
failCount++
break
}