add: more mod panel stats add: show user invite in mod panel add:

ability to share to twitter/bluesky
This commit is contained in:
trisua 2025-06-24 13:18:52 -04:00
parent 66beef6b1d
commit 2676340fba
8 changed files with 201 additions and 22 deletions

View file

@ -1,6 +1,6 @@
use crate::model::{Error, Result};
use super::{DataManager, drivers::common};
use oiseau::{cache::Cache, execute};
use oiseau::{cache::Cache, execute, query_row, params};
pub const NAME_REGEX: &str = r"[^\w_\-\.,!]+";
@ -52,6 +52,26 @@ impl DataManager {
Ok(())
}
pub async fn get_table_row_count(&self, table: &str) -> Result<i32> {
let conn = match self.0.connect().await {
Ok(c) => c,
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
};
let res = query_row!(
&conn,
&format!("SELECT COUNT(*)::int FROM {}", table),
params![],
|x| Ok(x.get::<usize, i32>(0))
);
if let Err(e) = res {
return Err(Error::DatabaseError(e.to_string()));
}
Ok(res.unwrap())
}
}
#[macro_export]