refactor: cut web results over to competition projections

This commit is contained in:
dahyeon committed 2026-07-12 20:11:24 +00:00
1 parent 7db97c540b
commit 6bddb666fc
13 files changed
+2153 -3885

No files matched your search

+18 -63
View File
@@ -9,11 +9,9 @@ import type {
ApiRiotRecentStatsSummary,
ApiTierHistoryEntry,
ApiTierInfo,
ApiDoubleEliminationBracket,
MatchStatus,
Position,
RiotLane,
TournamentCodeSlotView,
} from "./types";
import { POSITION_ORDER, teamIndexLabel } from "../lib/league";
@@ -52,40 +50,9 @@ export interface MatchDetailView {
description: string;
map: string;
maxParticipants: number;
gameCount: number;
gameMode: ApiMatch["gameMode"];
doubleElimination?: ApiDoubleEliminationBracket;
tournamentCodes: TournamentCodeSlotView[];
joined: boolean;
participants: ParticipantView[];
teams: TeamView[];
result?: {
winner?: string;
winnerTeamIndex?: number;
riotMatchIds: string[];
games: Array<{
gameNumber: number;
bracketMatchId?: string;
riotMatchId: string;
blueTeamIndex: number;
redTeamIndex: number;
winnerTeamIndex: number;
winnerSide: "blue" | "red";
gameCreation: number;
gameDuration: number;
participants: Array<{
userId: string;
teamIndex: number;
side: "blue" | "red";
championId: number;
kills: number;
deaths: number;
assists: number;
win: boolean;
}>;
}>;
seriesResults: NonNullable<ApiMatch["result"]>["seriesResults"];
};
prizes: string[];
notices: string[];
schedule: { time: string; label: string }[];
@@ -434,7 +401,9 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
captainUserId: team.captainUserId,
captainName:
captain?.summonerName ??
(team.captainUserId ? `User ${team.captainUserId.slice(-4)}` : undefined),
(team.captainUserId
? `User ${team.captainUserId.slice(-4)}`
: undefined),
captainTag: captain?.tag,
participants: team.members.map((member) => {
const participant =
@@ -450,10 +419,6 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
};
});
const winnerTeam = match.result?.winnerTeamIndex
? teams.find((team) => team.teamIndex === match.result?.winnerTeamIndex)
: undefined;
return {
id: match._id,
title: match.title,
@@ -463,24 +428,9 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
description: match.description,
map: mapIdToLabel(match.mapId),
maxParticipants: match.maxParticipants,
gameCount: match.gameCount ?? 3,
gameMode: match.gameMode ?? "pair",
doubleElimination: match.doubleElimination,
tournamentCodes: match.tournamentCodes ?? [],
joined: Boolean(match.joined),
participants,
teams,
result: match.result
? {
winner: match.result.winnerTeamIndex ? winnerTeam?.name : undefined,
winnerTeamIndex: match.result.winnerTeamIndex,
riotMatchIds: match.result.riotMatchIds,
games: [...(match.result.games ?? [])].sort(
(left, right) => left.gameNumber - right.gameNumber,
),
seriesResults: match.result.seriesResults ?? [],
}
: undefined,
prizes: match.prizes,
notices: match.notices,
schedule: match.schedule,
@@ -523,9 +473,9 @@ export function mapApiAuctionToAuctionState(
const auctionPlayerLookup = new Map(
auctionOrder.map((player) => [player.userId, player]),
);
const teams = rawAuctionTeams.map(normalizeApiAuctionTeam).sort(
(left, right) => left.teamIndex - right.teamIndex,
);
const teams = rawAuctionTeams
.map(normalizeApiAuctionTeam)
.sort((left, right) => left.teamIndex - right.teamIndex);
const totalPlayers = auctionOrder.length;
const currentPlayer =
@@ -535,7 +485,9 @@ export function mapApiAuctionToAuctionState(
rawAuctionOrder[currentAuctionPlayerOrderIndex]?.userId ?? "",
) ?? null);
const currentPlayerIndex =
auction.phase === "complete" ? totalPlayers : currentAuctionPlayerOrderIndex;
auction.phase === "complete"
? totalPlayers
: currentAuctionPlayerOrderIndex;
const remainingMs = currentBidRoundDeadlineTimestampMS
? Math.max(0, currentBidRoundDeadlineTimestampMS - now.getTime())
: 0;
@@ -557,11 +509,12 @@ export function mapApiAuctionToAuctionState(
auctionRound: auction.currentAuctionRound ?? auction.auctionRound ?? 1,
bids: normalizeApiAuctionBids(auction),
currentBid,
currentBidder: currentBidderTeamIndex !== undefined
? {
teamIndex: currentBidderTeamIndex,
}
: null,
currentBidder:
currentBidderTeamIndex !== undefined
? {
teamIndex: currentBidderTeamIndex,
}
: null,
remainingMs,
timer,
maxTimer: maximumBidRoundDurationSeconds,
@@ -574,7 +527,9 @@ export function mapApiAuctionToAuctionState(
type NormalizedApiAuctionTeam = ApiAuctionTeam & { points: number };
function normalizeApiAuctionTeam(team: ApiAuctionTeam): NormalizedApiAuctionTeam {
function normalizeApiAuctionTeam(
team: ApiAuctionTeam,
): NormalizedApiAuctionTeam {
return {
...team,
points: team.points ?? team.remainingBidPointAmount ?? 0,