systemprompt_analytics/services/
session_cleanup.rs1use crate::Result;
7use systemprompt_database::DbPool;
8
9use crate::repository::SessionRepository;
10
11#[derive(Clone, Debug)]
12pub struct SessionCleanupService {
13 session_repo: SessionRepository,
14}
15
16impl SessionCleanupService {
17 pub fn new(db_pool: &DbPool) -> Result<Self> {
18 Ok(Self {
19 session_repo: SessionRepository::new(db_pool)?,
20 })
21 }
22
23 pub async fn cleanup_inactive_sessions(&self, inactive_hours: i32) -> Result<u64> {
24 self.session_repo.cleanup_inactive(inactive_hours).await
25 }
26}