diff --git a/src/commands/count.rs b/src/commands/count.rs index b5713ea..0289c59 100644 --- a/src/commands/count.rs +++ b/src/commands/count.rs @@ -112,12 +112,13 @@ pub mod servers { } // get all members - let (wolves_current, wolves_past) = get_wolves_total(&db).await; - cs.push((wolves_current, wolves_past, String::from("Skynet Network"))); + let (wolves_current, wolves_past, total) = get_wolves_total(&db).await; + cs.push((total, total, String::from("Skynet Network"))); + cs.push((wolves_current, wolves_past, String::from("Clubs/Socs Servers"))); // treat teh committee server as its own thing let committee_current = get_wolves_committee(&db).await; - cs.push((committee_current, 0, String::from("Committee"))); + cs.push((committee_current, 0, String::from("Committee Server"))); cs.sort_by_key(|(current, _, _)| *current); cs.reverse(); @@ -164,24 +165,7 @@ pub mod servers { pub count: i64, } - async fn get_wolves_total(db: &Pool) -> (i64, i64) { - let total = match sqlx::query_as::<_, Count>( - r#" - SELECT COUNT(DISTINCT id_wolves) as count - FROM wolves - WHERE discord IS NOT NULL - "#, - ) - .fetch_one(db) - .await - { - Ok(res) => res.count, - Err(e) => { - dbg!(e); - 0 - } - }; - + async fn get_wolves_total(db: &Pool) -> (i64, i64, i64) { let current = match sqlx::query_as::<_, Count>( r#" SELECT COUNT(DISTINCT id_wolves) as count @@ -204,7 +188,43 @@ pub mod servers { } }; - (current, total) + let cns = match sqlx::query_as::<_, Count>( + r#" + SELECT COUNT(DISTINCT id_wolves) as count + FROM server_members + JOIN wolves USING (id_wolves) + WHERE wolves.discord IS NOT NULL + "#, + ) + .bind(get_now_iso(true)) + .fetch_one(db) + .await + { + Ok(res) => res.count, + Err(e) => { + dbg!(e); + 0 + } + }; + + let total = match sqlx::query_as::<_, Count>( + r#" + SELECT COUNT(DISTINCT id_wolves) as count + FROM wolves + WHERE discord IS NOT NULL + "#, + ) + .fetch_one(db) + .await + { + Ok(res) => res.count, + Err(e) => { + dbg!(e); + 0 + } + }; + + (current, cns, total) } async fn get_wolves_committee(db: &Pool) -> i64 {