Compare commits
No commits in common. "bded8d789f5dab0d55c013bd05112abb400c85cd" and "931d4b26e7fc8281431ff3254f3367716fd985bc" have entirely different histories.
bded8d789f
...
931d4b26e7
1 changed files with 2 additions and 45 deletions
|
|
@ -221,20 +221,11 @@ struct StatsQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn api_stats(
|
async fn api_stats(
|
||||||
State(state): State<AppState>,
|
State(_state): State<AppState>,
|
||||||
axum::extract::Query(q): axum::extract::Query<StatsQuery>,
|
axum::extract::Query(q): axum::extract::Query<StatsQuery>,
|
||||||
) -> axum::Json<crate::stats::Snapshot> {
|
) -> axum::Json<crate::stats::Snapshot> {
|
||||||
let window = crate::stats::Window::parse(q.window.as_deref().unwrap_or("24h"));
|
let window = crate::stats::Window::parse(q.window.as_deref().unwrap_or("24h"));
|
||||||
let mut snapshot = crate::stats::snapshot_default(window);
|
axum::Json(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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
|
@ -401,40 +392,6 @@ async fn recent_inbox(socket: &std::path::Path, flavor: Flavor) -> Vec<hive_sh4r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch reminder activity stats from the broker via the per-agent /
|
|
||||||
/// manager socket. Returns None on any transport / decode failure — the
|
|
||||||
/// stats are decorative, not authoritative.
|
|
||||||
async fn fetch_reminder_stats(socket: &std::path::Path, flavor: Flavor, window_secs: u64) -> Option<hive_sh4re::ReminderStats> {
|
|
||||||
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
|
// Action handlers
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue