Fetch the count of pending draft recommendations for every sandbox. This runs on the Dashboard tick so the sandbox list can show notification badges without entering the sandbox detail view.
(app: &mut App)
| 2429 | /// This runs on the Dashboard tick so the sandbox list can show notification |
| 2430 | /// badges without entering the sandbox detail view. |
| 2431 | async fn refresh_sandbox_draft_counts(app: &mut App) { |
| 2432 | let names: Vec<String> = app.sandbox_names.clone(); |
| 2433 | let mut counts = vec![0usize; names.len()]; |
| 2434 | for (i, name) in names.iter().enumerate() { |
| 2435 | let req = openshell_core::proto::GetDraftPolicyRequest { |
| 2436 | name: name.clone(), |
| 2437 | status_filter: "pending".to_string(), |
| 2438 | }; |
| 2439 | if let Ok(Ok(resp)) = |
| 2440 | tokio::time::timeout(Duration::from_secs(2), app.client.get_draft_policy(req)).await |
| 2441 | { |
| 2442 | counts[i] = resp.into_inner().chunks.len(); |
| 2443 | } |
| 2444 | } |
| 2445 | app.sandbox_draft_counts = counts; |
| 2446 | } |
| 2447 | |
| 2448 | fn phase_label(phase: i32) -> String { |
| 2449 | match phase { |
no test coverage detected