From 9bcbd566b600359fe5f784251a15572021257bd0 Mon Sep 17 00:00:00 2001 From: jedarden Date: Wed, 13 May 2026 17:56:19 -0400 Subject: [PATCH] Bug fix bf-3mx7: Fix match index winner badge - use p.Won instead of comparing BotID with WinnerID The WinnerID field is a player-slot integer as string (e.g. "2"), not a bot_id. The SQL query already computes the correct winner status in p.Won field. Fixed in 3 functions: - matchToSummary: Changed Won: p.BotID == m.WinnerID to Won: p.Won - buildPlaylistMatch: Changed Won: p.BotID == m.WinnerID to Won: p.Won - ratingUpsetMagnitude: Use p.Won to identify winner instead of comparing with m.WinnerID - maxScoreDiff: Use p.Won to identify winner instead of comparing with m.WinnerID - isEvolutionBreakthrough: Find winner using p.Won before checking if evolved This fixes the issue where 984/1000 prod matches had winner_id set but all participants showed won: false. Co-Authored-By: Claude Sonnet 4.6 --- cmd/acb-index-builder/generator.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cmd/acb-index-builder/generator.go b/cmd/acb-index-builder/generator.go index 2ab246d..ac0527a 100644 --- a/cmd/acb-index-builder/generator.go +++ b/cmd/acb-index-builder/generator.go @@ -352,7 +352,7 @@ func matchToSummary(m MatchData, data *IndexData, cfg *Config) MatchSummary { BotID: p.BotID, Name: name, Score: p.Score, - Won: p.BotID == m.WinnerID, + Won: p.Won, }) } @@ -979,7 +979,7 @@ func buildPlaylistMatch(m MatchData, order int, data *IndexData, curationTag str BotID: p.BotID, Name: name, Score: p.Score, - Won: p.BotID == m.WinnerID, + Won: p.Won, }) scoreParts = append(scoreParts, fmt.Sprintf("%d", p.Score)) } @@ -1010,7 +1010,7 @@ func ratingUpsetMagnitude(m MatchData) int { var winnerRating, bestLoserRating float64 found := false for _, p := range m.Participants { - if p.BotID == m.WinnerID { + if p.Won { winnerRating = p.PreMatchRating found = true } @@ -1019,7 +1019,7 @@ func ratingUpsetMagnitude(m MatchData) int { return 0 } for _, p := range m.Participants { - if p.BotID != m.WinnerID && p.PreMatchRating > bestLoserRating { + if !p.Won && p.PreMatchRating > bestLoserRating { bestLoserRating = p.PreMatchRating } } @@ -1161,14 +1161,14 @@ func maxScoreDiff(m MatchData) int { } var winnerScore int for _, p := range m.Participants { - if p.BotID == m.WinnerID { + if p.Won { winnerScore = p.Score break } } maxDiff := 0 for _, p := range m.Participants { - if p.BotID != m.WinnerID { + if !p.Won { diff := winnerScore - p.Score if diff > maxDiff { maxDiff = diff @@ -1249,10 +1249,21 @@ func isEvolutionBreakthrough(m MatchData, data *IndexData) bool { if m.WinnerID == "" || len(m.Participants) < 2 { return false } + var winnerBotID string + for _, p := range m.Participants { + if p.Won { + winnerBotID = p.BotID + break + } + } + if winnerBotID == "" { + return false + } winnerEvolved := false for _, bot := range data.Bots { - if bot.ID == m.WinnerID && bot.Evolved { + if bot.ID == winnerBotID && bot.Evolved { winnerEvolved = true + break } } if !winnerEvolved { @@ -1260,7 +1271,7 @@ func isEvolutionBreakthrough(m MatchData, data *IndexData) bool { } // Winner must have beaten someone rated >= 1600 for _, p := range m.Participants { - if p.BotID != m.WinnerID && p.PreMatchRating >= 1600 && !p.Won { + if !p.Won && p.PreMatchRating >= 1600 { return true } }