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 querypage
- Zero-based page number (e.g., 0 for first page, 1 for second page)per_page
- Number of records to fetch per pagestatus
- Optional filter for alert statusseverity
- Optional filter for alert severityorg_id
- Optional filter for organization IDapp_id
- Optional filter for application IDservice
- Optional filter for service namefrom_date
- Optional filter for alerts after this timestampto_date
- Optional filter for alerts before this timestamp
§Returns
Ok(Vec<Alert>)
- Successfully retrieved list of alertsErr(anyhow::Error)
- Failed to fetch alerts, with context