show total reminders and intervals on admin dash

This commit is contained in:
jude
2023-07-10 09:59:11 +01:00
parent dda8bd3e10
commit 1a1a0fdefb
3 changed files with 38 additions and 0 deletions

View File

@ -133,6 +133,30 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
.await
.unwrap();
let interval_count = sqlx::query!(
"SELECT COUNT(1) AS count
FROM reminders
WHERE
`interval_seconds` IS NOT NULL OR
`interval_months` IS NOT NULL OR
`interval_days` IS NOT NULL"
)
.fetch_one(pool.inner())
.await
.unwrap();
let reminder_count = sqlx::query!(
"SELECT COUNT(1) AS count
FROM reminders
WHERE
`interval_seconds` IS NULL AND
`interval_months` IS NULL AND
`interval_days` IS NULL"
)
.fetch_one(pool.inner())
.await
.unwrap();
Ok(json!({
"backlog": backlog.backlog,
"scheduleShort": {
@ -142,6 +166,10 @@ pub async fn bot_data(cookies: &CookieJar<'_>, pool: &State<Pool<MySql>>) -> Jso
"scheduleLong": {
"once": schedule_once_long,
"interval": schedule_interval_long,
},
"count": {
"reminders": reminder_count.count,
"intervals": interval_count.count,
}
}))
}