Commit 5ed5daf6 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(tools): shoot.mjs deletes the matches and rows its account creates

Bot game scenes create domino/ludo/backgammon match rows and, now that payouts
work, economy and rating rows; removeAccount left them behind. Twelve orphaned
domino matches from earlier runs were deleted from production.
Co-Authored-By: 's avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 00e13552
...@@ -116,10 +116,19 @@ async function removeAccount() { ...@@ -116,10 +116,19 @@ async function removeAccount() {
} }
if (!account) return; if (!account) return;
const id = account.id; const id = account.id;
// Bot games and matchmaking write rows of their own; every one goes with the
// account, or production fills with orphans.
for (const p of [`chat_messages?sender_id=eq.${id}`, `matchmaking_queue?player_id=eq.${id}`, for (const p of [`chat_messages?sender_id=eq.${id}`, `matchmaking_queue?player_id=eq.${id}`,
`mp_log?player_id=eq.${id}`, `matches?white_player_id=eq.${id}`, `mp_log?player_id=eq.${id}`, `matches?white_player_id=eq.${id}`,
`matches?black_player_id=eq.${id}`, `player_achievements?player_id=eq.${id}`, `matches?black_player_id=eq.${id}`, `player_achievements?player_id=eq.${id}`,
`rating_history?player_id=eq.${id}`, `profiles?id=eq.${id}`]) { `rating_history?player_id=eq.${id}`,
`domino_matches?players=cs.${encodeURIComponent(JSON.stringify([id]))}`,
`ludo_matches?host_id=eq.${id}`, `backgammon_matches?created_by=eq.${id}`,
`backgammon_matches?players=cs.${encodeURIComponent(JSON.stringify([id]))}`,
`domino_queue?user_id=eq.${id}`, `ludo_queue?user_id=eq.${id}`, `backgammon_queue?user_id=eq.${id}`,
`economy_transactions?player_id=eq.${id}`, `player_game_ratings?player_id=eq.${id}`,
`player_cosmetics?player_id=eq.${id}`, `notifications?user_id=eq.${id}`,
`profiles?id=eq.${id}`]) {
await sb(p, { method: 'DELETE' }).catch(() => {}); await sb(p, { method: 'DELETE' }).catch(() => {});
} }
await fetch(`${SB}/auth/v1/admin/users/${id}`, { method: 'DELETE', headers: { apikey: SK, Authorization: `Bearer ${SK}` } }).catch(() => {}); await fetch(`${SB}/auth/v1/admin/users/${id}`, { method: 'DELETE', headers: { apikey: SK, Authorization: `Bearer ${SK}` } }).catch(() => {});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment