Skip to content

Commit e7699c8

Browse files
fix: prism home api (#1245)
1. add critical severity alert count to alerts info 2. date level stats in sorted order
1 parent a8c8ed4 commit e7699c8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/alerts/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ pub struct AlertsInfo {
886886
low: u64,
887887
medium: u64,
888888
high: u64,
889+
critical: u64,
889890
}
890891

891892
// TODO: add RBAC
@@ -898,6 +899,7 @@ pub async fn get_alerts_info() -> Result<AlertsInfo, AlertError> {
898899
let mut low = 0;
899900
let mut medium = 0;
900901
let mut high = 0;
902+
let mut critical = 0;
901903

902904
for (_, alert) in alerts.iter() {
903905
total += 1;
@@ -911,7 +913,7 @@ pub async fn get_alerts_info() -> Result<AlertsInfo, AlertError> {
911913
Severity::Low => low += 1,
912914
Severity::Medium => medium += 1,
913915
Severity::High => high += 1,
914-
_ => {}
916+
Severity::Critical => critical += 1,
915917
}
916918
}
917919

@@ -923,5 +925,6 @@ pub async fn get_alerts_info() -> Result<AlertsInfo, AlertError> {
923925
low,
924926
medium,
925927
high,
928+
critical,
926929
})
927930
}

src/prism/home/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub async fn generate_home_response(key: &SessionKey) -> Result<HomeResponse, Pr
149149
let alerts_info = get_alerts_info().await?;
150150

151151
// generate dates for date-wise stats
152-
let dates = (0..7)
152+
let mut dates = (0..7)
153153
.map(|i| {
154154
Utc::now()
155155
.checked_sub_signed(chrono::Duration::days(i))
@@ -158,6 +158,7 @@ pub async fn generate_home_response(key: &SessionKey) -> Result<HomeResponse, Pr
158158
})
159159
.map(|date| date.format("%Y-%m-%d").to_string())
160160
.collect_vec();
161+
dates.reverse();
161162

162163
let mut stream_details = Vec::new();
163164

0 commit comments

Comments
 (0)