Skip to main content

systemprompt_analytics/repository/agents/
mod.rs

1//! Agent analytics queries over `agent_tasks` and joined `ai_requests`.
2//!
3//! [`AgentAnalyticsRepository`] aggregates per-agent task counts, success
4//! rates, execution time, and cost, exposing list, detail, and summary-stat
5//! reads split across the sibling query submodules.
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10mod detail_queries;
11mod list_queries;
12mod stats_queries;
13
14use crate::Result;
15use sqlx::PgPool;
16use std::sync::Arc;
17use systemprompt_database::DbPool;
18
19#[derive(Debug)]
20pub struct AgentAnalyticsRepository {
21    pool: Arc<PgPool>,
22}
23
24impl AgentAnalyticsRepository {
25    pub fn new(db: &DbPool) -> Result<Self> {
26        let pool = db.pool_arc()?;
27        Ok(Self { pool })
28    }
29}