feat: add leaderboard cache, performance benchmarks, and verify SSE cleanup
- Add 30s TTL leaderboard cache with invalidation on fight completion - Add scoreRound performance benchmark: 1000 rounds in <100ms - Add checkAnswer performance benchmark: 1000 checks in <50ms - Add adversarial regex backtracking test for checkAnswer - Verify SSE cleanup: connections, IP counters, spectator counts, event listeners all properly decremented in finally block on disconnect Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
7d9b8b1dbf
commit
4074ef94eb
@@ -17,6 +17,7 @@ import { publishFightResult } from './nostr-publish.js'
|
||||
import { getCurrentSeason } from './seasons.js'
|
||||
import { onFightFinished as onTournamentFightFinished } from './tournaments.js'
|
||||
import { trackFightCompleted, trackBotActive, trackMetric } from './analytics.js'
|
||||
import { invalidateLeaderboardCache } from '../routes/bots.js'
|
||||
|
||||
const webhookResponseSchema = z.object({
|
||||
answer: z.string().nullable().optional(),
|
||||
@@ -539,6 +540,9 @@ async function executeFightRounds(fightId: string, botA: BotRecord, botB: BotRec
|
||||
trackMetric(`challenge_${ct}`)
|
||||
}
|
||||
|
||||
// Invalidate leaderboard cache after Elo/stats update
|
||||
invalidateLeaderboardCache()
|
||||
|
||||
// Advance tournament bracket if this was a tournament match
|
||||
try { onTournamentFightFinished(fightId, winnerId ?? null) } catch { /* not a tournament fight */ }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user