Show game number for Game #2+ in series, hide Game #1 for single-game matchups
If a matchup has only one game (game #1), the number is redundant — show just the round name. If game #2 or higher is upcoming, it clearly belongs to a multi-game series, so show the game number to distinguish it. https://claude.ai/code/session_01CRrqu43FKHshpJt1NyrDdX
This commit is contained in:
parent
6f51ad8c78
commit
6d6508d503
2 changed files with 34 additions and 4 deletions
|
|
@ -388,6 +388,24 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
|
|||
expect(result[0].matchLabel).toBeNull();
|
||||
});
|
||||
|
||||
it("shows game number when game #2+ is upcoming (multi-game series)", async () => {
|
||||
const rows = [{
|
||||
id: "e1", name: "PDC World Championship", eventDate: "2025-04-10",
|
||||
eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID,
|
||||
participant1Id: "man-city", participant2Id: "arsenal",
|
||||
round: "Semifinals", gameNumber: 2, scheduledAt: null,
|
||||
}];
|
||||
mockDb.selectDistinct.mockReturnValue(makeSelectChain(rows));
|
||||
|
||||
const result = await getUpcomingEventsForDraftedParticipants(
|
||||
SPORTS_SEASON_ID, "playoff_bracket",
|
||||
[makeParticipant("man-city", "Man City")],
|
||||
DATE_FROM, DATE_TO
|
||||
);
|
||||
|
||||
expect(result[0].matchLabel).toBe("Semifinals Game #2");
|
||||
});
|
||||
|
||||
it("all-compete events have null earliestGameTime and matchLabel", async () => {
|
||||
const participants = [makeParticipant("p1", "Verstappen")];
|
||||
mockDb.query.scoringEvents.findMany.mockResolvedValue([
|
||||
|
|
|
|||
|
|
@ -528,10 +528,22 @@ export async function getUpcomingEventsForDraftedParticipants(
|
|||
|
||||
// Build matchLabel from game keys
|
||||
const gameKeys = gameKeysByEvent.get(eventId) ?? new Set<string>();
|
||||
if (gameKeys.size >= 1) {
|
||||
// Only show the round name, not game numbers. Game numbers are only
|
||||
// relevant when there are multiple games in a matchup (e.g. Game #2),
|
||||
// but "Game #1" is redundant when there's only one game.
|
||||
if (gameKeys.size === 1) {
|
||||
const [round, gameNumberStr] = [...gameKeys][0].split("|");
|
||||
const gameNumber = parseInt(gameNumberStr, 10);
|
||||
if (gameNumber > 1) {
|
||||
// Game #2+ indicates a multi-game series — show the game number so
|
||||
// users can tell which game in the series is upcoming.
|
||||
event.matchLabel =
|
||||
round === event.name
|
||||
? `Game #${gameNumberStr}`
|
||||
: `${round} Game #${gameNumberStr}`;
|
||||
} else {
|
||||
// Single game (game #1 only) — no number needed, just show the round.
|
||||
event.matchLabel = round === event.name ? null : round;
|
||||
}
|
||||
} else if (gameKeys.size > 1) {
|
||||
// Multiple games across the matchup — use just the round name.
|
||||
const rounds = new Set([...gameKeys].map((k) => k.split("|")[0]));
|
||||
if (rounds.size === 1) {
|
||||
const round = [...rounds][0];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue