Skip to main content

systemprompt_analytics/repository/core_stats/
mod.rs

1//! Core platform statistics aggregated from analytics tables.
2//!
3//! [`CoreStatsRepository`] backs the dashboard overview, activity trends,
4//! categorical breakdowns, and leaderboards, with the read queries split
5//! across the sibling submodules.
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10mod activity;
11mod breakdowns;
12mod leaderboards;
13mod overview;
14
15use crate::Result;
16use sqlx::PgPool;
17use std::sync::Arc;
18use systemprompt_database::DbPool;
19
20#[derive(Debug)]
21pub struct CoreStatsRepository {
22    pool: Arc<PgPool>,
23}
24
25impl CoreStatsRepository {
26    pub fn new(db: &DbPool) -> Result<Self> {
27        let pool = db.pool_arc()?;
28        Ok(Self { pool })
29    }
30}