Prefer matches with a winner for home page featured battle

Filter the match pool to those with winner_id set before selecting
the featured replay, so a stalemate is never shown as the hero replay.
Falls back to any completed match if no decided matches exist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-04-30 17:56:48 -04:00
parent 250140d0f7
commit 74ab553925

View file

@ -22,7 +22,11 @@ async function findFeaturedReplay(
);
if (completed.length === 0) return { match: null, enriched: false };
const sorted = [...completed].sort(
// Prefer matches with a winner (no stalemates on the home page)
const withWinner = completed.filter((m) => !!m.winner_id);
const pool = withWinner.length > 0 ? withWinner : completed;
const sorted = [...pool].sort(
(a, b) =>
new Date(b.completed_at!).getTime() -
new Date(a.completed_at!).getTime(),