diff --git a/hive-ag3nt/src/web_ui.rs b/hive-ag3nt/src/web_ui.rs index 4e35833..45a4a60 100644 --- a/hive-ag3nt/src/web_ui.rs +++ b/hive-ag3nt/src/web_ui.rs @@ -221,20 +221,11 @@ struct StatsQuery { } async fn api_stats( - State(state): State, + State(_state): State, axum::extract::Query(q): axum::extract::Query, ) -> axum::Json { let window = crate::stats::Window::parse(q.window.as_deref().unwrap_or("24h")); - let mut snapshot = crate::stats::snapshot_default(window); - // Fetch reminder stats from the broker. The window spans are: - // 24h = 86400s, 7d = 604800s, 30d = 2592000s. - let window_secs = match window { - crate::stats::Window::Day => 24 * 3600, - crate::stats::Window::Week => 7 * 24 * 3600, - crate::stats::Window::Month => 30 * 24 * 3600, - }; - snapshot.reminder_stats = fetch_reminder_stats(&state.socket, state.flavor(), window_secs as u64).await; - axum::Json(snapshot) + axum::Json(crate::stats::snapshot_default(window)) } #[derive(Serialize)] @@ -401,40 +392,6 @@ async fn recent_inbox(socket: &std::path::Path, flavor: Flavor) -> Vec Option { - match flavor { - Flavor::Agent => { - match client::request::<_, hive_sh4re::AgentResponse>( - socket, - &hive_sh4re::AgentRequest::ReminderRollup { - since_secs: window_secs, - }, - ) - .await - { - Ok(hive_sh4re::AgentResponse::ReminderRollup(stats)) => Some(stats), - _ => None, - } - } - Flavor::Manager => { - match client::request::<_, hive_sh4re::ManagerResponse>( - socket, - &hive_sh4re::ManagerRequest::ReminderRollup { - since_secs: window_secs, - }, - ) - .await - { - Ok(hive_sh4re::ManagerResponse::ReminderRollup(stats)) => Some(stats), - _ => None, - } - } - } -} - // --------------------------------------------------------------------------- // Action handlers // ---------------------------------------------------------------------------