Skip to content

Commit 1049426

Browse files
author
Thord Setsaas
committed
Ensure correct current player is set on tournament playoffs
1 parent b927070 commit 1049426

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#### Fixed
1010
- Endpoints for getting player 170 statistics
11+
- Ensure that currenet player is set correctly on tournament playoffs
1112

1213
## [2.9.0] - 2025-04-06
1314
#### Feature

data/match.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,15 +868,16 @@ func SwapPlayers(matchID int, newPlayerID int, oldPlayerID int) error {
868868
return err
869869
}
870870

871-
// Update current player of the leg
872-
_, err = tx.Exec("UPDATE leg SET current_player_id = ? WHERE match_id = ?", newPlayerID, matchID)
871+
// Update player2leg
872+
_, err = tx.Exec("UPDATE player2leg SET player_id = ? WHERE match_id = ? AND player_id = ?", newPlayerID, matchID, oldPlayerID)
873873
if err != nil {
874874
tx.Rollback()
875875
return err
876876
}
877877

878-
// Update player2leg
879-
_, err = tx.Exec("UPDATE player2leg SET player_id = ? WHERE match_id = ? AND player_id = ?", newPlayerID, matchID, oldPlayerID)
878+
// Update current player of the leg
879+
//_, err = tx.Exec("UPDATE leg SET current_player_id = ? WHERE match_id = ?", newPlayerID, matchID)
880+
_, err = tx.Exec("UPDATE leg SET current_player_id = (SELECT player_id FROM player2leg WHERE match_id = ? AND `order` = 1) WHERE match_id = ?", matchID, matchID)
880881
if err != nil {
881882
tx.Rollback()
882883
return err

0 commit comments

Comments
 (0)