systemprompt_analytics/repository/fingerprint/
mod.rs1mod mutations;
2mod queries;
3
4use std::sync::Arc;
5
6use anyhow::Result;
7use sqlx::PgPool;
8use systemprompt_database::DbPool;
9
10pub const MAX_SESSIONS_PER_FINGERPRINT: i32 = 5;
11pub const HIGH_REQUEST_THRESHOLD: i64 = 100;
12pub const HIGH_VELOCITY_RPM: f32 = 10.0;
13pub const SUSTAINED_VELOCITY_MINUTES: i32 = 60;
14pub const ABUSE_THRESHOLD_FOR_BAN: i32 = 3;
15
16#[derive(Clone, Debug)]
17pub struct FingerprintRepository {
18 pool: Arc<PgPool>,
19}
20
21impl FingerprintRepository {
22 pub fn new(db: &DbPool) -> Result<Self> {
23 let pool = db.pool_arc()?;
24 Ok(Self { pool })
25 }
26}