YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: add force_refresh to /stats, reduce cache to 1h (today stats change)
Louis Beaumont6426a29d8c0c
diff --git a/crates/screenpipe-engine/src/server.rs b/crates/screenpipe-engine/src/server.rsindex 8d26a4bd2..15f440507 100644--- a/crates/screenpipe-engine/src/server.rs+++ b/crates/screenpipe-engine/src/server.rs@@ -166,8 +166,15 @@ pub struct AppState {async fn stats_handler(axum::extract::State(state): axum::extract::State<Arc<AppState>>,+ query: axum::extract::Query<std::collections::HashMap<String, String>>,) -> axum::Json<crate::stats::UserStats> {- axum::Json(crate::stats::get_stats(&state.db).await)+ let force = query.get("force_refresh").map(|v| v == "true").unwrap_or(false);+ let stats = if force {+ crate::stats::refresh_stats(&state.db).await+ } else {+ crate::stats::get_stats(&state.db).await+ };+ axum::Json(stats)}pub struct SCServer {diff --git a/crates/screenpipe-engine/src/stats.rs b/crates/screenpipe-engine/src/stats.rsindex 6eaa47736..550701525 100644--- a/crates/screenpipe-engine/src/stats.rs+++ b/crates/screenpipe-engine/src/stats.rs@@ -12,8 +12,8 @@ use serde::{Deserialize, Serialize};use tokio::sync::RwLock;use tracing::debug;-/// How long the cache is valid (24 hours).-const CACHE_TTL_SECS: u64 = 86400;+/// How long the cache is valid (1 hour — today's stats change throughout the day).+const CACHE_TTL_SECS: u64 = 3600;/// Cached stats with timestamp.static STATS_CACHE: std::sync::LazyLock<RwLock<(u64, Option<UserStats>)>> =