-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: Add private-leaderboard command #12
Conversation
That looks great, thank you! |
@@ -317,3 +320,103 @@ pub fn read( | |||
println!("\n{}", from_read(desc.as_bytes(), col_width)); | |||
Ok(()) | |||
} | |||
|
|||
fn get_private_leaderboard_results( | |||
args: &Args, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need args here
} | ||
|
||
#[derive(Deserialize)] | ||
struct Member { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simplify this by implementing TryFrom<&Value> for Member
so we only load the fields we need. We could even count the number of stars for each day then rather than when we're writing to the terminal. This would avoid all the fields xxx are never read
clippy warnings.
session: &str, | ||
leaderboard: &str, | ||
) -> AocResult<()> { | ||
let (year, day) = puzzle_year_day(args.year, args.day)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of calling puzzle_year_day
we need a new function. Something that: 1) unwraps the year if given or returns the latest event year, e.g. let year = args.year.unwrap_or_else(latest_event_year);
and 2) returns the last unlocked day for the selected year.
I'll merge this as it is and will do some minor changes to make Clippy happy |
Adds a private leaderboard command to print the results of a given private leaderboard.
Example output is similar to that on the website - but without colors or headers.