Function list_alerts

Source
pub async fn list_alerts(
    pool: &Pool<MySql>,
    page: i64,
    per_page: i64,
    status: Option<&str>,
    severity: Option<&str>,
    org_id: Option<i64>,
    app_id: Option<i64>,
    service: Option<&str>,
    from_date: Option<DateTime<Utc>>,
    to_date: Option<DateTime<Utc>>,
) -> Result<Vec<Alert>>
Expand description

Retrieves a paginated list of alerts from the database.

This function fetches a subset of alerts based on pagination parameters, ordering them by timestamp in descending order (newest first). Filtering options allow for narrowing down results by various criteria.

§Arguments

  • pool - Database connection pool for executing the query
  • page - Zero-based page number (e.g., 0 for first page, 1 for second page)
  • per_page - Number of records to fetch per page
  • status - Optional filter for alert status
  • severity - Optional filter for alert severity
  • org_id - Optional filter for organization ID
  • app_id - Optional filter for application ID
  • service - Optional filter for service name
  • from_date - Optional filter for alerts after this timestamp
  • to_date - Optional filter for alerts before this timestamp

§Returns

  • Ok(Vec<Alert>) - Successfully retrieved list of alerts
  • Err(anyhow::Error) - Failed to fetch alerts, with context