Function update_alert_status

Source
pub async fn update_alert_status(
    pool: &Pool<MySql>,
    id: i64,
    new_status: &str,
    user_id: Option<i64>,
    notes: Option<&str>,
) -> Result<Alert>
Expand description

Updates the status of an alert.

This function changes the status of an alert and records the change in the alert history table. It can mark alerts as acknowledged, resolved, or auto-resolved based on system or user actions.

§Arguments

  • pool - Database connection pool for executing the query
  • id - Unique identifier of the alert to update
  • new_status - New status for the alert (active, acknowledged, resolved, auto_resolved)
  • user_id - Optional ID of the user who performed the action
  • notes - Optional notes about the status change

§Returns

  • Ok(Alert) - Successfully updated alert
  • Err(anyhow::Error) - Failed to update alert