Skip to main content

systemprompt_analytics/services/
session_cleanup.rs

1//! Inactive-session cleanup service.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use crate::Result;
7
8use crate::repository::SessionRepository;
9
10#[derive(Clone, Debug)]
11pub struct SessionCleanupService {
12    session_repo: SessionRepository,
13}
14
15impl SessionCleanupService {
16    pub const fn new(session_repo: SessionRepository) -> Self {
17        Self { session_repo }
18    }
19
20    pub async fn cleanup_inactive_sessions(&self, inactive_hours: i32) -> Result<u64> {
21        self.session_repo.cleanup_inactive(inactive_hours).await
22    }
23}