pub async fn auto_resolve_old_alerts(
pool: &Pool<MySql>,
days_threshold: i64,
severity_levels: Option<Vec<&str>>,
) -> Result<i64>
Expand description
Auto-resolves alerts that have been active for longer than a specified period.
This function updates the status of old alerts to ‘auto_resolved’ based on criteria such as age, severity, and current status. It’s typically used for housekeeping to prevent the accumulation of stale alerts.
§Arguments
pool
- Database connection pool for executing the querydays_threshold
- Age in days after which an alert should be auto-resolvedseverity_levels
- Optional vector of severity levels to include (e.g., only auto-resolve ‘info’ alerts)
§Returns
Ok(i64)
- Number of alerts auto-resolvedErr(anyhow::Error)
- Failed to auto-resolve alerts