Skip to content

Commit

Permalink
Merge pull request #4 from WISVCH/bugfix/add-rank
Browse files Browse the repository at this point in the history
add rank to TodayEntry
  • Loading branch information
praseodym authored Dec 20, 2024
2 parents fa2744f + f9627f7 commit 9182711
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const ANON_USER: &str = "Anonymous User";
pub struct TodayEntry {
pub name: Option<String>,
pub score: i32,
pub rank: i32,
pub star1: Option<String>,
pub star2: Option<String>,
}
Expand All @@ -38,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
Expand Down Expand Up @@ -99,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(())
Expand Down Expand Up @@ -156,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(())
Expand Down

0 comments on commit 9182711

Please sign in to comment.