From b83a71dd6b340069925d420182af6d38a9458b93 Mon Sep 17 00:00:00 2001 From: Jeffrey de Lange Date: Fri, 20 Dec 2024 13:11:07 +0100 Subject: [PATCH 1/2] add rank to TodayEntry --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index da5cc43..f64edb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ const ANON_USER: &str = "Anonymous User"; pub struct TodayEntry { pub name: Option, pub score: i32, + pub rank: i32, pub star1: Option, pub star2: Option, } From f9627f7288e4cfc3bdd1239ffa3f0dda71724c65 Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:45:38 +0100 Subject: [PATCH 2/2] Run `cargo clippy --fix` --- src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index f64edb0..6a4ad07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,13 +39,12 @@ fn truncate(s: &str, max_chars: usize) -> &str { } async fn get_leaderboard_data() -> AochData { - let response_data = reqwest::get("https://aoch.wisv.ch/data") + reqwest::get("https://aoch.wisv.ch/data") .await .unwrap() .json() .await - .unwrap(); - response_data + .unwrap() } /// Displays the overall leaderboard of this year @@ -100,7 +99,7 @@ async fn leaderboard_total(ctx: Context<'_>) -> Result<(), Error> { ); let mut stylized_answer = table_rows[0..cmp::min(row_count, table_rows.len())].join("\n"); - stylized_answer = format!("```\n{}```", truncate(&*stylized_answer, 1990)); + stylized_answer = format!("```\n{}```", truncate(&stylized_answer, 1990)); ctx.say(stylized_answer).await?; Ok(()) @@ -157,7 +156,7 @@ async fn leaderboard_today(ctx: Context<'_>) -> Result<(), Error> { ); let mut stylized_answer = table_rows[0..cmp::min(row_count, table_rows.len())].join("\n"); - stylized_answer = format!("```\n{}```", truncate(&*stylized_answer, 1990)); + stylized_answer = format!("```\n{}```", truncate(&stylized_answer, 1990)); println!("{}", stylized_answer); ctx.say(stylized_answer).await?; Ok(())