Skip to main content

systemprompt_analytics/repository/costs/
mod.rs

1//! Cost analytics repository.
2//!
3//! Aggregates microdollar-precision AI request costs from `ai_requests`.
4//! [`platform`] holds platform-wide rollups; [`per_user`] holds the
5//! user-scoped cost and conversation-context queries.
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10mod per_user;
11mod platform;
12
13use crate::Result;
14use sqlx::PgPool;
15use std::sync::Arc;
16use systemprompt_database::DbPool;
17
18#[derive(Debug)]
19pub struct CostAnalyticsRepository {
20    pool: Arc<PgPool>,
21}
22
23impl CostAnalyticsRepository {
24    pub fn new(db: &DbPool) -> Result<Self> {
25        let pool = db.pool_arc()?;
26        Ok(Self { pool })
27    }
28}