Function add_alert_history

Source
pub async fn add_alert_history(
    pool: &Pool<MySql>,
    alert_id: i64,
    action: &str,
    performed_by: Option<i64>,
    notes: Option<&str>,
    previous_state: Option<Value>,
    new_state: Option<Value>,
) -> Result<AlertHistory>
Expand description

Adds a custom history entry for an alert.

This function allows adding arbitrary history records for an alert, which is useful for tracking manual interventions or system actions that don’t fit into predefined categories.

§Arguments

  • pool - Database connection pool for executing the query
  • alert_id - ID of the alert
  • action - Description of the action being recorded
  • performed_by - Optional ID of the user who performed the action
  • notes - Optional notes about the action
  • previous_state - Optional JSON data representing the state before the action
  • new_state - Optional JSON data representing the state after the action

§Returns

  • Ok(AlertHistory) - Successfully created history record
  • Err(anyhow::Error) - Failed to create history record