移除冗余代码
This commit is contained in:
@@ -12,7 +12,7 @@ server:
|
||||
|
||||
# 日志配置
|
||||
log:
|
||||
level: "info" # 日志级别: "debug", "info", "warn", "error", "dpanic", "panic", "fatal"
|
||||
level: "debug" # 日志级别: "debug", "info", "warn", "error", "dpanic", "panic", "fatal"
|
||||
format: "console" # 日志格式: "console" 或 "json"
|
||||
enable_file: true # 是否启用文件日志
|
||||
file_path: "./app_logs/app.log" # 日志文件路径
|
||||
|
||||
@@ -405,16 +405,9 @@ func (r *gormAlarmRepository) buildGroupAClause(tx *gorm.DB, configuredLevels []
|
||||
tx = tx.Where("1 = 1")
|
||||
}
|
||||
|
||||
// A.2. 构造 Group A 核心逻辑 (LastNotifiedAt IS NULL 且满足忽略条件)
|
||||
|
||||
// C_A_Ignored: 被忽略 且 仅发送一次 (忽略期已在前置任务中解除)
|
||||
ignoredQuery := tx.Where("is_ignored = ? AND last_notified_at IS NULL", true)
|
||||
|
||||
// C_A_NotIgnored: 未被忽略 且 仅发送一次
|
||||
notIgnoredQuery := tx.Where("is_ignored = ? AND last_notified_at IS NULL", false)
|
||||
|
||||
// A.3. 组合 Group A 核心逻辑: (C_A_Ignored OR C_A_NotIgnored)
|
||||
return tx.Where(ignoredQuery).Or(notIgnoredQuery)
|
||||
// A.2. 构造 Group A 核心逻辑 (LastNotifiedAt IS NULL 且未被忽略)
|
||||
// 由于前置任务已处理忽略状态,这里只需筛选未被忽略且未通知过的告警
|
||||
return tx.Where("is_ignored = ? AND last_notified_at IS NULL", false)
|
||||
}
|
||||
|
||||
// buildGroupBClause 构造 Group B 的 WHERE 语句和参数列表。
|
||||
@@ -440,18 +433,9 @@ func (r *gormAlarmRepository) buildGroupBClause(tx *gorm.DB, intervalByLevel map
|
||||
iccQuery = iccQuery.Or(sql, level, now)
|
||||
}
|
||||
|
||||
// B.3. 组合 Group B 核心逻辑: (last_notified_at IS NULL OR [ICC])
|
||||
|
||||
// C_B_NotIgnored: 未被忽略
|
||||
notIgnoredQuery := tx.Where("is_ignored = ?", false).Where(
|
||||
tx.Where("last_notified_at IS NULL").Or(iccQuery), // LastNotifiedAt IS NULL OR ICC
|
||||
// B.3. 组合 Group B 核心逻辑: (is_ignored = false AND (last_notified_at IS NULL OR [ICC]))
|
||||
// 由于前置任务已处理忽略状态,这里只需筛选未被忽略且满足通知条件的告警
|
||||
return tx.Where("is_ignored = ?", false).Where(
|
||||
tx.Session(&gorm.Session{}).Where("last_notified_at IS NULL").Or(iccQuery),
|
||||
)
|
||||
|
||||
// C_B_Ignored: 被忽略 (忽略期已在前置任务中解除)
|
||||
ignoredQuery := tx.Where("is_ignored = ?", true).Where(
|
||||
tx.Where("last_notified_at IS NULL").Or(iccQuery), // LastNotifiedAt IS NULL OR ICC
|
||||
)
|
||||
|
||||
// B.4. 组合 Group B 核心逻辑: (C_B_NotIgnored OR C_B_Ignored)
|
||||
return tx.Where(notIgnoredQuery).Or(ignoredQuery)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user