feat: rewrite scheduled_tasks in rust

This commit is contained in:
alyssa 2024-12-28 02:40:58 +00:00
parent 4bfee8a090
commit 0862964305
20 changed files with 419 additions and 715 deletions

View file

@ -3,6 +3,19 @@ pub async fn get_stats(pool: &sqlx::postgres::PgPool) -> anyhow::Result<Counts>
Ok(counts)
}
pub async fn insert_stats(
pool: &sqlx::postgres::PgPool,
table: &str,
value: i64,
) -> anyhow::Result<()> {
// danger sql injection
sqlx::query(format!("insert into {table} values (now(), $1)").as_str())
.bind(value)
.execute(pool)
.await?;
Ok(())
}
#[derive(serde::Serialize, sqlx::FromRow)]
pub struct Counts {
pub system_count: i64,