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