systemprompt-analytics 0.2.1

Analytics for systemprompt.io AI governance infrastructure. Session, agent, tool, and microdollar-precision cost attribution across the MCP governance pipeline.
Documentation
use anyhow::Result;
use systemprompt_database::DbPool;

use crate::repository::SessionRepository;

#[derive(Clone, Debug)]
pub struct SessionCleanupService {
    session_repo: SessionRepository,
}

impl SessionCleanupService {
    pub fn new(db_pool: &DbPool) -> Result<Self> {
        Ok(Self {
            session_repo: SessionRepository::new(db_pool)?,
        })
    }

    pub async fn cleanup_inactive_sessions(&self, inactive_hours: i32) -> Result<u64> {
        self.session_repo.cleanup_inactive(inactive_hours).await
    }
}