From 126ce53951f11d14e4f69aa46d733dc4eba76536 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Tue, 10 Feb 2026 14:38:18 -0600 Subject: [PATCH] fix: Sort games chronologically in standings recalculation for accurate streaks The standings recalculate function was processing games in arbitrary database order, causing win/loss streaks to be calculated incorrectly. Added explicit ordering by week and game_num (ascending) to ensure games are processed chronologically. This fixes inconsistent streak values that were reported due to the streak logic depending on processing games in the correct temporal sequence. Co-Authored-By: Claude Sonnet 4.5 --- app/db_engine.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/db_engine.py b/app/db_engine.py index 1ecb218..3b7af32 100644 --- a/app/db_engine.py +++ b/app/db_engine.py @@ -1326,7 +1326,8 @@ class Standings(BaseModel): # Iterate through each individual result # for game in Result.select_season(season).where(Result.week <= 22): for game in StratGame.select().where( - (StratGame.season == season) & (StratGame.week <= 18) & (StratGame.game_num.is_null(False))): + (StratGame.season == season) & (StratGame.week <= 18) & (StratGame.game_num.is_null(False)) + ).order_by(StratGame.week, StratGame.game_num): # tally win and loss for each standings object game.update_standings()