Fix player stats bug

master
Tait Hoyem 10 months ago
parent 22fdb8f5f0
commit be994c8ef7

@ -447,9 +447,9 @@ impl Player {
ON goals.shooter=game_players.id ON goals.shooter=game_players.id
AND goals.goal=true AND goals.goal=true
LEFT JOIN shots assists LEFT JOIN shots assists
ON (points.assistant=game_players.id ON (assists.assistant=game_players.id
OR points.assistant_second=game_players.id) OR assists.assistant_second=game_players.id)
AND points.goal=true AND assists.goal=true
WHERE players.id=$1 WHERE players.id=$1
GROUP BY players.id; GROUP BY players.id;
"#; "#;
@ -754,7 +754,14 @@ mod tests {
fn check_lifetime_stats() { fn check_lifetime_stats() {
tokio_test::block_on(async move { tokio_test::block_on(async move {
let pool = db_connect().await; let pool = db_connect().await;
let lifetime_stats = Player::lifetime_stats(&pool, 5).await.unwrap(); let lifetime_stats = Player::lifetime_stats(&pool, 1).await.unwrap();
assert_eq!(lifetime_stats.goals, 1);
assert_eq!(lifetime_stats.assists, 1);
assert_eq!(lifetime_stats.points, 2);
let hilary_lifetime_stats = Player::lifetime_stats(&pool, 2).await.unwrap();
assert_eq!(hilary_lifetime_stats.goals, 17);
assert_eq!(hilary_lifetime_stats.assists, 1);
assert_eq!(hilary_lifetime_stats.points, 18);
}) })
} }

Loading…
Cancel
Save