From f5ac164eda547dc9edb936a1907694f23511fd69 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 20 Feb 2026 14:06:21 -0600 Subject: [PATCH] store: Fix: Win percentage orientation bug - sheet gives leading team's win%, not home team's --- ...on-bug-sheet-gives-leading-teams-4c2c50.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 graph/fixes/fix-win-percentage-orientation-bug-sheet-gives-leading-teams-4c2c50.md diff --git a/graph/fixes/fix-win-percentage-orientation-bug-sheet-gives-leading-teams-4c2c50.md b/graph/fixes/fix-win-percentage-orientation-bug-sheet-gives-leading-teams-4c2c50.md new file mode 100644 index 00000000000..3b1e339dac1 --- /dev/null +++ b/graph/fixes/fix-win-percentage-orientation-bug-sheet-gives-leading-teams-4c2c50.md @@ -0,0 +1,37 @@ +--- +id: 4c2c50d7-febe-43f6-a264-d586b24f49d6 +type: fix +title: "Fix: Win percentage orientation bug - sheet gives leading team's win%, not home team's" +tags: [major-domo, scorebug, win-probability, fix, orientation, google-sheets, discord-bot] +importance: 0.75 +confidence: 0.8 +created: "2026-02-20T20:06:21.331952+00:00" +updated: "2026-02-20T20:06:21.331952+00:00" +--- + +# Fix: Win Percentage Orientation Bug + +## Problem +The Google Sheet Scorebug tab outputs: +- `C8` = winning team abbreviation +- `D8` = that team's win probability percentage + +The code was treating `D8` as the home team's win% unconditionally. When the away team was winning (e.g., DEN at 95%), the progress bar incorrectly showed the home team (MKE) as favored at 95%. + +## Root Cause +`create_team_progress_bar()` always expects the value from the home team's perspective. The sheet does not guarantee that perspective — it gives the leading team's perspective. + +## Fix (`services/scorebug_service.py`) +1. Read `C8` (`all_data[6][1]`) to get the leading team abbreviation. +2. Compare it to the home team abbreviation from `game_state[4][1]`. +3. If the leading team is the **away** team, flip the value: `win_percentage = 100 - win_percentage`. + +This ensures `create_team_progress_bar` always receives the correct home-team-perspective value. + +## Key Detail +Sheet row/column indices (0-based): +- `all_data[6][1]` = C8 (leading team abbreviation) +- `game_state[4][1]` = home team abbreviation + +## Closes +Issue #38 (implied by scorebug bug batch). Branch: `fix/scorebug-bugs`.