-
Notifications
You must be signed in to change notification settings - Fork 1
fix: remove sentinel-player dependency in teams-left #54
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -506,10 +506,9 @@ sub count_player_teams_left { | |
| from games_played | ||
| ), | ||
| games_remaining as ( | ||
| select p.game | ||
| from pick p | ||
| where p.player = 24 | ||
| and p.game not in (select game from games_played) | ||
| select g.id as game | ||
| from game g | ||
| where g.id not in (select game from games_played) | ||
| ), | ||
| player_teams_remaining as ( | ||
| select player, pick | ||
|
|
@@ -529,7 +528,10 @@ sub count_player_teams_left { | |
| foreach my $row (@{$result}) { | ||
| $teams_left_per_player->{$row->[0]} = $row->[1]; | ||
| } | ||
| my $max_left = max map { $teams_left_per_player->{$_} } grep { $_ != 1 } keys %{$teams_left_per_player}; | ||
| my @players = grep { $_ != 1 } keys %{$teams_left_per_player}; | ||
| my $max_left = @players | ||
| ? max(map { $teams_left_per_player->{$_} } @players) | ||
| : 0; | ||
| return $teams_left_per_player, $max_left; | ||
| } | ||
| ); | ||
|
|
@@ -566,10 +568,9 @@ sub count_player_final4_teams_left { | |
| from games_played | ||
| ), | ||
| games_remaining as ( | ||
| select p.game | ||
| from pick p | ||
| where p.player = 24 | ||
| and p.game not in (select game from games_played) | ||
| select g.id as game | ||
| from game g | ||
| where g.id not in (select game from games_played) | ||
| ), | ||
| player_teams_remaining as ( | ||
| select player, pick | ||
|
|
@@ -594,7 +595,10 @@ sub count_player_final4_teams_left { | |
| foreach my $row (@{$result}) { | ||
| $final4_teams_left_per_player->{$row->[0]} = $row->[1]; | ||
| } | ||
| my $max_left = max map { $final4_teams_left_per_player->{$_} } grep { $_ != 1 } keys %{$final4_teams_left_per_player}; | ||
| my @players = grep { $_ != 1 } keys %{$final4_teams_left_per_player}; | ||
| my $max_left = @players | ||
| ? max(map { $final4_teams_left_per_player->{$_} } @players) | ||
| : 0; | ||
|
Comment on lines
+598
to
+601
|
||
| return $final4_teams_left_per_player, $max_left; | ||
| } | ||
| ); | ||
|
|
||
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.
The new empty-non-admin-player branch for $max_left (returning 0 when there are no players other than player 1 in the result map) isn’t covered by tests. Add a regression case where only the admin/perfect player exists (or where no non-admin players have remaining teams) and assert $max_left is 0, to prevent reintroducing the previous max-on-empty behavior.