systemprompt_users/repository/banned_ip/
mod.rs1mod listing;
12mod queries;
13mod types;
14
15use std::sync::Arc;
16
17use crate::error::Result;
18use sqlx::PgPool;
19use systemprompt_database::DbPool;
20
21pub use types::{BanDuration, BanIpParams, BanIpWithMetadataParams, BannedIp};
22
23#[derive(Clone, Debug)]
24pub struct BannedIpRepository {
25 pool: Arc<PgPool>,
26 write_pool: Arc<PgPool>,
27}
28
29impl BannedIpRepository {
30 pub fn new(db: &DbPool) -> Result<Self> {
31 let pool = db.pool_arc()?;
32 let write_pool = db.write_pool_arc()?;
33 Ok(Self { pool, write_pool })
34 }
35
36 pub fn from_pool(pool: Arc<PgPool>) -> Self {
37 let write_pool = Arc::clone(&pool);
38 Self { pool, write_pool }
39 }
40}