stats: add 1h, 4h, 3d time range windows
Adds Hour (5-min buckets), FourHour (15-min buckets), and ThreeDay (hourly buckets) to the Window enum, plus the matching tab buttons in stats.html. Simplifies web_ui.rs to use Window::span_secs() instead of a duplicate match. Closes #25
This commit is contained in:
parent
4bb3877460
commit
f9d1e69a50
3 changed files with 24 additions and 10 deletions
|
|
@ -319,13 +319,9 @@ async fn api_stats(
|
|||
) -> axum::Json<crate::stats::Snapshot> {
|
||||
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,
|
||||
};
|
||||
// Pass the window span to the reminder-stats RPC so the broker
|
||||
// filters its counts to the same time range as the chart data.
|
||||
let window_secs = window.span_secs();
|
||||
snapshot.reminder_stats = fetch_reminder_stats(&state.socket, state.flavor(), window_secs as u64).await;
|
||||
axum::Json(snapshot)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue