Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rank to TodayEntry #4

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading