/// Updates a Players games_played and games_won field, returns an Err if the
/// specified name is not in the database.
Updates a Players games_played and games_won field, returns an Err if the
specified name is not in the database.
Updates a Players games_played and games_won field returns an Err if the specified name is not in the database .
pub async fn player_played_round(
    connection: &PgPool,
    player_name: &PlayerName,
    won: bool,
) -> Result<Player, ()> {
    match query_player_by_name(connection, player_name).await {
        Some(mut player) => {
            player.games_played += 1;
            if won {
                player.games_won += 1;
            }
            match update_player_stats(connection, &player).await {
                Ok(_) => Ok(player),
                Err(_) => Err(()),
            }
        }
        None => Err(()),
    }
}
pub async fn player_played_round ( connection : & PgPool , player_name : & PlayerName , won : bool , ) -> Result < Player , ( ) > { match query_player_by_name ( connection , player_name ) . await { Some ( mut player ) => { player . games_played += 1 ; if won { player . games_won += 1 ; } match update_player_stats ( connection , & player ) . await { Ok ( _ ) => Ok ( player ) , Err ( _ ) => Err ( ( ) ) , } } None => Err ( ( ) ) , } }
Updates a Players games_played and games_won field, returns an Err if the
specified name is not in the database.
Updates a Players games_played and games_won field returns an Err if the specified name is not in the database .
connection
&PgPool
player_name
&PlayerName
won
bool