fix: pin playoff card to its own gameNumber so the header doesn't tick forward after a final
series_state derives game_number from topSeedWins + bottomSeedWins + 1, which becomes the *next* game's number once the API advances seriesStatus post-final. The card for the just-finished game would then read "Game N+1 of 7". Prefer the raw gameNumber on the game payload, falling back to the derived value when it's missing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -65,6 +65,7 @@ def make_playoff_game(
|
||||
bottom_abbrev="BOS",
|
||||
top_is_home=True,
|
||||
game_state="LIVE",
|
||||
game_number=None,
|
||||
**kwargs,
|
||||
):
|
||||
"""Convenience wrapper around make_game for playoff fixtures.
|
||||
@@ -87,7 +88,7 @@ def make_playoff_game(
|
||||
home_abbrev, away_abbrev = bottom_abbrev, top_abbrev
|
||||
home_name, away_name = "Bottom Seeds", "Top Seeds"
|
||||
|
||||
return make_game(
|
||||
game = make_game(
|
||||
game_state=game_state,
|
||||
game_type=3,
|
||||
series_status=series_status,
|
||||
@@ -97,6 +98,9 @@ def make_playoff_game(
|
||||
away_name=kwargs.pop("away_name", away_name),
|
||||
**kwargs,
|
||||
)
|
||||
if game_number is not None:
|
||||
game["gameNumber"] = game_number
|
||||
return game
|
||||
|
||||
|
||||
LIVE_GAME = make_game()
|
||||
|
||||
@@ -149,6 +149,12 @@ class TestSeriesSummary:
|
||||
game = make_playoff_game(top_wins=1, bottom_wins=1)
|
||||
assert series_summary(game) == "Game 3 of 7"
|
||||
|
||||
def test_finished_game_keeps_its_own_number(self):
|
||||
# seriesStatus has advanced to 2-0 after this game finished, but the
|
||||
# raw gameNumber pins the card to the game it actually represents.
|
||||
game = make_playoff_game(top_wins=2, bottom_wins=0, game_number=2)
|
||||
assert series_summary(game) == "Game 2 of 7"
|
||||
|
||||
|
||||
class TestIsPinned:
|
||||
def test_game7_live_is_pinned(self):
|
||||
|
||||
Reference in New Issue
Block a user