Skip to main content

systemprompt_analytics/services/
session_cleanup.rs

1use anyhow::Result;
2use systemprompt_database::DbPool;
3
4use crate::repository::SessionRepository;
5
6#[derive(Clone, Debug)]
7pub struct SessionCleanupService {
8    session_repo: SessionRepository,
9}
10
11impl SessionCleanupService {
12    #[allow(clippy::missing_const_for_fn)]
13    pub fn new(db_pool: DbPool) -> Self {
14        Self {
15            session_repo: SessionRepository::new(db_pool),
16        }
17    }
18
19    pub async fn cleanup_inactive_sessions(&self, inactive_hours: i32) -> Result<u64> {
20        self.session_repo.cleanup_inactive(inactive_hours).await
21    }
22}