-
Notifications
You must be signed in to change notification settings - Fork 0
Track per-team solve attempts with timestamped correctness state #30
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
Draft
Copilot
wants to merge
18
commits into
main
Choose a base branch
from
copilot/store-solve-attempt-times
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8590bba
Initial plan
Copilot dc9005c
Store timed solve attempts with correctness state
Copilot c82a9f1
refactor: bool instead of enum
jarjk cb12c60
chore(readme): inline html -> md (so `bun` can render it)
jarjk 6b78ab7
Initial plan
Copilot 606807e
Initial plan
Copilot ffc960d
Store timed solve attempts with correctness state
Copilot e8cabeb
Initial plan
Copilot 7b5c493
Merge remote-tracking branch 'origin/copilot/store-solve-attempt-time…
Copilot 1addf7c
ci: build with older glibc for more compatibility
jarjk 0403f29
chore(make): more thorough clean
jarjk dbf908c
ci: disable `wild` for now
jarjk 42c62f9
ci: build linux with musl
jarjk 7bb4608
ci: keep gnu
jarjk 6f6af4b
Initial plan
Copilot 87e3433
Initial plan
Copilot d14e90c
Initial plan
Copilot ea9765e
Initial plan
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,4 @@ | |
| **/Cargo.lock | ||
| assets/tailwind.css | ||
|
|
||
| .**-apollo-sid.cookie | ||
| .*-apollo-sid.cookie | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| use dioxus::fullstack::serde; | ||
| use std::collections::{HashMap, HashSet}; | ||
| use std::collections::HashMap; | ||
| use std::time::SystemTime; | ||
|
|
||
| // SECURITY: SecretString, with manual impls? | ||
| #[derive(Clone, PartialOrd, Ord, PartialEq, Eq, serde::Deserialize, serde::Serialize)] | ||
|
|
@@ -20,7 +21,56 @@ pub type PuzzleSolutionHash = String; | |
| pub type PuzzlesExisting = HashMap<PuzzleId, PuzzleValue>; | ||
| /// all the puzzles with their values and solutions | ||
| pub type PuzzleSolutions = HashMap<PuzzleId, Puzzle>; | ||
| /// solved puzzles of a team | ||
| pub type SolvedPuzzles = HashSet<PuzzleId>; | ||
| /// progress of each team, which puzzles they've solved | ||
| pub type TeamsState = HashMap<String, SolvedPuzzles>; | ||
|
|
||
| #[derive(Clone, PartialOrd, Ord, PartialEq, Eq, serde::Deserialize, serde::Serialize)] | ||
| #[serde(crate = "dioxus::fullstack::serde")] | ||
| pub struct SolveAttempt { | ||
| pub puzzle_id: PuzzleId, | ||
| pub attempted_at: SystemTime, | ||
| pub correct: bool, | ||
| } | ||
| impl SolveAttempt { | ||
| pub fn now(puzzle_id: PuzzleId, correct: bool) -> Self { | ||
| Self { | ||
| puzzle_id, | ||
| attempted_at: SystemTime::now(), | ||
| correct, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// all solve attempts of a team | ||
| pub type TeamAttempts = Vec<SolveAttempt>; | ||
| /// progress of each team, which puzzles they attempted and when | ||
| pub type TeamsState = HashMap<String, TeamAttempts>; | ||
|
|
||
| pub fn team_has_solved_puzzle(team_attempts: &[SolveAttempt], puzzle_id: &str) -> bool { | ||
| team_attempts | ||
| .iter() | ||
| .any(|attempt| attempt.puzzle_id == puzzle_id && attempt.correct) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::{SolveAttempt, team_has_solved_puzzle}; | ||
| use std::time::UNIX_EPOCH; | ||
|
|
||
| #[test] | ||
| fn marks_puzzle_as_solved_only_for_correct_attempts() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't actually test anything, have a look at |
||
| let team_attempts = vec![ | ||
| SolveAttempt { | ||
| puzzle_id: "p1".into(), | ||
| attempted_at: UNIX_EPOCH, | ||
| correct: false, | ||
| }, | ||
| SolveAttempt { | ||
| puzzle_id: "p1".into(), | ||
| attempted_at: UNIX_EPOCH, | ||
| correct: true, | ||
| }, | ||
| ]; | ||
|
|
||
| assert!(team_has_solved_puzzle(&team_attempts, "p1")); | ||
| assert!(!team_has_solved_puzzle(&team_attempts, "p2")); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why new var?