Skip to content

fix: prism home api #1245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/alerts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ pub struct AlertsInfo {
low: u64,
medium: u64,
high: u64,
critical: u64,
}

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

for (_, alert) in alerts.iter() {
total += 1;
Expand All @@ -911,7 +913,7 @@ pub async fn get_alerts_info() -> Result<AlertsInfo, AlertError> {
Severity::Low => low += 1,
Severity::Medium => medium += 1,
Severity::High => high += 1,
_ => {}
Severity::Critical => critical += 1,
}
}

Expand All @@ -923,5 +925,6 @@ pub async fn get_alerts_info() -> Result<AlertsInfo, AlertError> {
low,
medium,
high,
critical,
})
}
3 changes: 2 additions & 1 deletion src/prism/home/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub async fn generate_home_response(key: &SessionKey) -> Result<HomeResponse, Pr
let alerts_info = get_alerts_info().await?;

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

let mut stream_details = Vec::new();

Expand Down
Loading