systemprompt_analytics/services/
session_cleanup.rs1use 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 pub fn new(db_pool: &DbPool) -> Result<Self> {
13 Ok(Self {
14 session_repo: SessionRepository::new(db_pool)?,
15 })
16 }
17
18 pub async fn cleanup_inactive_sessions(&self, inactive_hours: i32) -> Result<u64> {
19 self.session_repo.cleanup_inactive(inactive_hours).await
20 }
21}