From 6743d1f67057f0a770d8849cd481f5677409aade Mon Sep 17 00:00:00 2001 From: jedarden Date: Mon, 20 Apr 2026 23:37:22 -0400 Subject: [PATCH] fix(index-builder): use player_slot when comparing to matches.winner matches.winner is an INTEGER (player slot), not a bot_id VARCHAR. Fix two queries that compared mp.bot_id = m.winner (type mismatch) to use mp.player_slot = m.winner. Co-Authored-By: Claude Sonnet 4.6 --- cmd/acb-index-builder/db.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/acb-index-builder/db.go b/cmd/acb-index-builder/db.go index cd51992..ad5e60c 100644 --- a/cmd/acb-index-builder/db.go +++ b/cmd/acb-index-builder/db.go @@ -239,7 +239,7 @@ func fetchBots(ctx context.Context, db *sql.DB) ([]BotData, error) { func getBotMatchStats(ctx context.Context, db *sql.DB, botID string) (played, won int, err error) { query := ` - SELECT COUNT(*), COUNT(*) FILTER (WHERE mp.bot_id = m.winner) + SELECT COUNT(*), COUNT(*) FILTER (WHERE mp.player_slot = m.winner) FROM match_participants mp JOIN matches m ON mp.match_id = m.match_id WHERE mp.bot_id = $1 AND m.status = 'completed' @@ -258,7 +258,7 @@ func fetchMatches(ctx context.Context, db *sql.DB) ([]MatchData, error) { 'bot_id', mp.bot_id, 'player_slot', mp.player_slot, 'score', mp.score, - 'won', mp.bot_id = m.winner + 'won', mp.player_slot = m.winner ) ORDER BY mp.player_slot ) FILTER (WHERE mp.bot_id IS NOT NULL),