brewlog/src/application/routes/api/analytics/stats.rs
Jon Seager edc0021792
refactor: split large directories into coffee/auth/analytics subdirs
- Restructure domain/, repositories/, and routes/api/ into themed
  subdirectories: coffee/, auth/, analytics/ (and system/ for routes)
- Convert super:: relative imports to crate:: absolute paths
- Promote macro visibility from pub(super) to pub(crate)
- Add pub use re-exports for backward-compatible import paths
2026-02-08 18:16:16 +00:00

27 lines
800 B
Rust

use axum::Json;
use axum::extract::State;
use crate::application::auth::AuthenticatedUser;
use crate::application::errors::{ApiError, AppError};
use crate::application::services::stats::compute_all_stats;
use crate::application::state::AppState;
use crate::domain::stats::CachedStats;
/// Force an immediate stats recomputation, bypassing the debounce timer.
#[tracing::instrument(skip(state, _auth_user))]
pub(crate) async fn recompute_stats(
State(state): State<AppState>,
_auth_user: AuthenticatedUser,
) -> Result<Json<CachedStats>, ApiError> {
let cached = compute_all_stats(&*state.stats_repo)
.await
.map_err(AppError::from)?;
state
.stats_repo
.store_cached(&cached)
.await
.map_err(AppError::from)?;
Ok(Json(cached))
}