Function auto_resolve_old_alerts

Source
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 query
  • days_threshold - Age in days after which an alert should be auto-resolved
  • severity_levels - Optional vector of severity levels to include (e.g., only auto-resolve ‘info’ alerts)

§Returns

  • Ok(i64) - Number of alerts auto-resolved
  • Err(anyhow::Error) - Failed to auto-resolve alerts