feat: season leaderboard with toggle and countdown

Add GET /api/bots/leaderboard?season=current endpoint. LeaderboardPage
now toggles between "This Season" and "All Time" views. Shows season
name, countdown timer, and top 3 placement badges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-08 20:16:04 +00:00
co-authored by Claude Opus 4.6
parent ecac2bf246
commit e229bfb8fc
2 changed files with 161 additions and 41 deletions
+43
View File
@@ -149,6 +149,49 @@ botsRouter.get('/:name', async (c) => {
})
// Get bot stats -- full account page data
// Season leaderboard endpoint
botsRouter.get('/leaderboard', async (c) => {
const seasonParam = c.req.query('season')
if (seasonParam === 'current' || seasonParam) {
const { getCurrentSeason, getSeasonLeaderboard, getSeasonById } = await import('../engine/seasons.js')
const season = seasonParam === 'current' ? getCurrentSeason() : getSeasonById(seasonParam)
if (!season) return c.json({ error: 'Season not found' }, 404)
const entries = await getSeasonLeaderboard(season.id)
return c.json({ season, entries })
}
// All-time: fall through to default bot list sorted by Elo
const allBots = await db.select({
id: schema.bots.id,
name: schema.bots.name,
avatarSeed: schema.bots.avatarSeed,
archetype: schema.bots.archetype,
eloRating: schema.bots.eloRating,
wins: schema.bots.wins,
losses: schema.bots.losses,
winStreak: schema.bots.winStreak,
tier: schema.bots.tier,
botType: schema.bots.botType,
}).from(schema.bots)
const ranked = allBots.filter(b => b.botType !== 'classic')
ranked.sort((a, b) => b.eloRating - a.eloRating)
return c.json({ season: null, entries: ranked.map(b => ({
botId: b.id,
botName: b.name,
archetype: b.archetype,
tier: b.tier,
wins: b.wins,
losses: b.losses,
eloRating: b.eloRating,
avatarSeed: b.avatarSeed,
winStreak: b.winStreak,
})) })
})
botsRouter.get('/:name/stats', async (c) => {
const name = c.req.param('name')
const ownerPubkey = c.req.query('pubkey')