show total reminders and intervals on admin dash
This commit is contained in:
		| @@ -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, | ||||
|         } | ||||
|     })) | ||||
| } | ||||
|   | ||||
| @@ -3,6 +3,8 @@ document.addEventListener("DOMContentLoaded", () => { | ||||
|         .then((resp) => resp.json()) | ||||
|         .then((data) => { | ||||
|             document.querySelector("#backlog").textContent = data.backlog; | ||||
|             document.querySelector("#reminders").textContent = data.count.reminders; | ||||
|             document.querySelector("#intervals").textContent = data.count.intervals; | ||||
|  | ||||
|             new Chart(document.getElementById("schedule"), { | ||||
|                 type: "bar", | ||||
|   | ||||
| @@ -46,6 +46,14 @@ | ||||
|             <p>Backlog</p> | ||||
|             <p class="figure-num" id="backlog">?</p> | ||||
|         </div> | ||||
|         <div class="stat-box figure"> | ||||
|             <p>Reminders</p> | ||||
|             <p class="figure-num" id="reminders">?</p> | ||||
|         </div> | ||||
|         <div class="stat-box figure"> | ||||
|             <p>Intervals</p> | ||||
|             <p class="figure-num" id="intervals">?</p> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="stat-row"> | ||||
|         <div class="stat-box" style="height: 400px;"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user