diff --git a/hive-ag3nt/assets/stats.html b/hive-ag3nt/assets/stats.html
index 2c30597..66a6a8d 100644
--- a/hive-ag3nt/assets/stats.html
+++ b/hive-ag3nt/assets/stats.html
@@ -68,7 +68,10 @@
+
+
+
diff --git a/hive-ag3nt/src/stats.rs b/hive-ag3nt/src/stats.rs
index bf95b45..f22165f 100644
--- a/hive-ag3nt/src/stats.rs
+++ b/hive-ag3nt/src/stats.rs
@@ -20,7 +20,10 @@ use hive_sh4re::ReminderStats;
/// total span + the bucket width used to roll up trend series.
#[derive(Debug, Clone, Copy)]
pub enum Window {
+ Hour,
+ FourHour,
Day,
+ ThreeDay,
Week,
Month,
}
@@ -28,6 +31,9 @@ pub enum Window {
impl Window {
pub fn parse(s: &str) -> Self {
match s {
+ "1h" => Self::Hour,
+ "4h" => Self::FourHour,
+ "3d" => Self::ThreeDay,
"7d" => Self::Week,
"30d" => Self::Month,
_ => Self::Day,
@@ -36,15 +42,21 @@ impl Window {
fn label(self) -> &'static str {
match self {
+ Self::Hour => "1h",
+ Self::FourHour => "4h",
Self::Day => "24h",
+ Self::ThreeDay => "3d",
Self::Week => "7d",
Self::Month => "30d",
}
}
- fn span_secs(self) -> i64 {
+ pub fn span_secs(self) -> i64 {
match self {
+ Self::Hour => 3600,
+ Self::FourHour => 4 * 3600,
Self::Day => 24 * 3600,
+ Self::ThreeDay => 3 * 24 * 3600,
Self::Week => 7 * 24 * 3600,
Self::Month => 30 * 24 * 3600,
}
@@ -52,8 +64,11 @@ impl Window {
fn bucket_secs(self) -> i64 {
match self {
- // hourly for the 24h view, daily for the longer ranges.
- Self::Day => 3600,
+ // 5-min buckets for 1h (12 buckets), 15-min for 4h (16 buckets),
+ // hourly for 24h + 3d, daily for 7d + 30d.
+ Self::Hour => 300,
+ Self::FourHour => 900,
+ Self::Day | Self::ThreeDay => 3600,
Self::Week | Self::Month => 24 * 3600,
}
}
diff --git a/hive-ag3nt/src/web_ui.rs b/hive-ag3nt/src/web_ui.rs
index a172bac..bbd1e76 100644
--- a/hive-ag3nt/src/web_ui.rs
+++ b/hive-ag3nt/src/web_ui.rs
@@ -319,13 +319,9 @@ async fn api_stats(
) -> 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,
- };
+ // 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)
}