mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 08:09:22 +00:00
@@ -682,6 +682,15 @@ pub async fn list(
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets a list of alerts from the database `ORM_CLIENT`.
|
||||
pub async fn list_with_folders_db(
|
||||
params: ListAlertsParams,
|
||||
) -> Result<Vec<(Folder, Alert)>, AlertError> {
|
||||
let conn = ORM_CLIENT.get_or_init(connect_to_orm).await;
|
||||
db::alerts::alert::list_with_folders(conn, params)
|
||||
.await
|
||||
.map_err(|e| e.into())
|
||||
}
|
||||
/// Gets a list of alerts.
|
||||
pub async fn list_v2<C: ConnectionTrait>(
|
||||
conn: &C,
|
||||
|
||||
@@ -17,7 +17,8 @@ use std::io::{Error, ErrorKind};
|
||||
|
||||
use config::{
|
||||
meta::{
|
||||
dashboards::ListDashboardsParams, pipeline::components::PipelineSource, stream::StreamType,
|
||||
alerts::alert::ListAlertsParams, dashboards::ListDashboardsParams,
|
||||
pipeline::components::PipelineSource, stream::StreamType,
|
||||
},
|
||||
utils::rand::generate_random_string,
|
||||
};
|
||||
@@ -65,10 +66,12 @@ pub async fn get_summary(org_id: &str) -> OrgSummary {
|
||||
.count() as i64,
|
||||
};
|
||||
|
||||
let alerts = db::alerts::alert::list(org_id, None, None).await.unwrap();
|
||||
let alerts = super::alerts::alert::list_with_folders_db(ListAlertsParams::new(org_id))
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
let alert_summary = AlertSummary {
|
||||
num_realtime: alerts.iter().filter(|a| a.is_real_time).count() as i64,
|
||||
num_scheduled: alerts.iter().filter(|a| !a.is_real_time).count() as i64,
|
||||
num_realtime: alerts.iter().filter(|(_, a)| a.is_real_time).count() as i64,
|
||||
num_scheduled: alerts.iter().filter(|(_, a)| !a.is_real_time).count() as i64,
|
||||
};
|
||||
|
||||
let functions = db::functions::list(org_id).await.unwrap_or_default();
|
||||
|
||||
Reference in New Issue
Block a user