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
7mod per_user;
8mod platform;
9
10use crate::Result;
11use sqlx::PgPool;
12use std::sync::Arc;
13use systemprompt_database::DbPool;
14
15#[derive(Debug)]
16pub struct CostAnalyticsRepository {
17 pool: Arc<PgPool>,
18}
19
20impl CostAnalyticsRepository {
21 pub fn new(db: &DbPool) -> Result<Self> {
22 let pool = db.pool_arc()?;
23 Ok(Self { pool })
24 }
25}