-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement /post/game route #10
base: main
Are you sure you want to change the base?
Conversation
#[post("/post/game")] | ||
async fn post_game(data: Data<RwLock<AppData>>, game: Json<GameStats>) -> impl Responder { | ||
let res = { | ||
let mut data = data.write().unwrap(); // Needs better error handling -- esp. with if the RwLock is poisoned |
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.
let mut data = data.write().unwrap(); // Needs better error handling -- esp. with if the RwLock is poisoned | |
let mut data = data.write().unwrap(); // Needs better error handling -- esp. with if the RwLock is poisoned |
We could use parking_lot
, which has an RwLock
without poisoning.
data.stats.merge(stats); | ||
data.games.push(game); |
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.
Do we want to check if the game is already present (by checking the round_date
)?
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 should check if the game already exists (by comparing the round date) and return an appropriate response (an error or something like an empty JSON) in that case.
Co-authored-by: konsumlamm <[email protected]>
serde_repr = "0.1" | ||
serde_repr = "0.1" |
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.
Can you readd the trailing newline?
impl<T> Merge for Option<T> | ||
where | ||
T: Merge, | ||
{ | ||
fn merge(&mut self, other: Self) { | ||
match (self, other) { | ||
// (Some, Some) | ||
(Some(v), Some(other)) => v.merge(other), | ||
|
||
// (None, Some) | ||
(s, Some(other)) => *s = Some(other), | ||
|
||
// (None, None) or (Some, None) | ||
_ => (), | ||
} | ||
} | ||
} |
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.
What is this used for?
@@ -1,2911 +1,4114 @@ | |||
{ | |||
"KillFeed":[{ |
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.
Can you undo this reformat?
Co-authored-by: konsumlamm <[email protected]>
This would have the benefit of adding games while the server is running.
But it would slow down initial building of the stats.