feat: connect tournament views to APIs and recover archived stats

Remove development previews and complete hall of fame, match history, official results, and multi-kill API integration.

Fix active match pagination and team-ready controls, preserve basic scoreboards, and recover statistics when Riot archives arrive.

Use bounded in-process cache invalidation retries and add the Riot match lookup index migration with regression coverage.
This commit is contained in:
dahyeon committed 2026-11-11 02:00:35 +09:00
1 parent 20e1e6ec04
commit 0d7617e2d2
70 files changed
+3739 -1793

No files matched your search

@@ -0,0 +1,87 @@
import { Link, useLocation } from "react-router";
import type { ApiInternalMatchDetailResponse, DdragonManifest } from "../api/types";
import { championDisplayName, championIconUrl } from "../lib/ddragon";
import { teamIndexLabel } from "../lib/league";
import { EmptyNote } from "../ui";
export function GameAnalysisNotice() {
return (
<EmptyNote
size="sm"
title="Riot 원본이 없는 경기 기록"
description="저장된 경기 결과와 선수별 KDA를 볼 수 있습니다."
/>
);
}
export function BasicGameScoreboard({
game,
teams,
manifest,
}: {
game: ApiInternalMatchDetailResponse["games"][number];
teams: ApiInternalMatchDetailResponse["match"]["teams"];
manifest: DdragonManifest | null | undefined;
}) {
const location = useLocation();
const backTo = `${location.pathname}${location.search}${location.hash}`;
return (
<div className="space-y-3 p-4">
{game.analysisAvailability && game.analysisAvailability !== "available" && (
<GameAnalysisNotice />
)}
{game.teams.map((team) => (
<section key={team.side} className="overflow-hidden rounded-lg border border-line bg-card">
<h4 className="border-b border-line px-3 py-2 text-sm font-semibold">
{teamIndexLabel(team.teamIndex, teams.find(({ teamIndex }) => teamIndex === team.teamIndex)?.name)}
{" · "}{team.side === "blue" ? "블루" : "레드"}{" · "}{team.win ? "승리" : "패배"}
</h4>
{team.participants.length > 0 ? (
<table className="w-full text-left text-sm">
<thead className="text-xs text-content-muted">
<tr>
<th scope="col" className="px-3 py-2">선수</th>
<th scope="col" className="px-3 py-2">챔피언</th>
<th scope="col" className="px-3 py-2 text-right">K/D/A</th>
</tr>
</thead>
<tbody className="divide-y divide-line">
{team.participants.map((participant) => {
const icon = championIconUrl(manifest, participant.championId);
const champion = championDisplayName(manifest, participant.championId);
return (
<tr key={`${participant.userId}-${participant.championId}`}>
<td className="px-3 py-2">
{participant.userId ? (
<Link
to={`/users/${participant.userId}/history?queueGroup=internal`}
state={{ backTo }}
className="font-semibold hover:underline"
>
{participant.summonerName}
</Link>
) : participant.summonerName}
</td>
<td className="px-3 py-2">
<span className="flex items-center gap-2">
{icon && <img src={icon} alt="" className="size-6 rounded" />}
{champion ?? "챔피언 미확인"}
</span>
</td>
<td className="whitespace-nowrap px-3 py-2 text-right tabular">
{participant.kills}/{participant.deaths}/{participant.assists}
</td>
</tr>
);
})}
</tbody>
</table>
) : (
<p className="px-3 py-2 text-sm text-content-muted">저장된 선수 기록이 없습니다.</p>
)}
</section>
))}
</div>
);
}
+121 -132
View File
@@ -1,8 +1,8 @@
import type { MatchPosition } from '@lolympus/contracts';
import type { HallOfFameResponse, MatchPosition } from '@lolympus/contracts';
import { ChevronRight, UserRound } from 'lucide-react';
import { useEffect, useRef, useState, type CSSProperties } from 'react';
import { Link } from 'react-router';
import { useDdragonManifest } from '../api/hooks';
import { useDdragonManifest, useHallOfFame } from '../api/hooks';
import captainCrown from '../assets/captain-crown.svg';
import pixelTrophy from '../assets/pixel-trophy.svg';
import { profileIconUrl } from '../lib/ddragon';
@@ -10,61 +10,14 @@ import { positionLabel } from '../lib/league';
import { pageWidthClass } from '../ui/layout';
import './HomeHallOfFame.css';
// The roster featured on the home page is curated independently of match results.
const FEATURED_TEAM = {
name: '똥칼라파워',
captainUserId: '69f090029bf765ff8e54faae',
members: [
{
userId: '6a36268cf3a6fd12921ca016',
position: 'TOP',
gameName: 'ALLM',
tagLine: 'ALL',
profileIconId: 6091,
},
{
userId: '69f090029bf765ff8e54faae',
position: 'JGL',
gameName: 'OPIS',
tagLine: '2283',
profileIconId: 7146,
},
{
userId: '69f090039bf765ff8e54facf',
position: 'MID',
gameName: '우 킨',
tagLine: '안우킨',
profileIconId: 6622,
},
{
userId: '6a37c488f3a6fd12921cf2b4',
position: 'ADC',
gameName: '말 안해도 알잖아',
tagLine: 'Ф x Ф',
profileIconId: 6379,
},
{
userId: '69f090069bf765ff8e54fb5a',
position: 'SUP',
gameName: '툭치면 크르릉',
tagLine: 'KR1',
profileIconId: 4020,
},
] satisfies Array<{
userId: string;
position: MatchPosition;
gameName: string;
tagLine: string;
profileIconId: number;
}>,
};
const POSITION_ORDER: MatchPosition[] = ['TOP', 'JGL', 'MID', 'ADC', 'SUP'];
export default function HomeHallOfFame({
introReady,
}: {
introReady: boolean;
}) {
const { data: manifest } = useDdragonManifest();
const hallOfFame = useHallOfFame();
const sectionRef = useRef<HTMLElement>(null);
const [playIntro, setPlayIntro] = useState(false);
@@ -89,95 +42,131 @@ export default function HomeHallOfFame({
return () => observer.disconnect();
}, [introReady]);
const featuredMatch = hallOfFame.data?.match;
return (
// The second grid column is left empty on purpose: it reserves room for a
// small companion card beside the hall of fame.
<section
ref={sectionRef}
aria-labelledby="home-hall-of-fame"
aria-label="명예의 전당"
className={`${pageWidthClass()} lts-hall grid gap-8 py-6 md:py-8 lg:grid-cols-[minmax(0,1fr)_20rem]`}
data-intro={playIntro ? '' : undefined}
>
<div className="lts-hall-card flex min-w-0 flex-col gap-4 bg-card p-5 sm:flex-row sm:gap-5">
<h2 className="min-w-0 sm:w-36 sm:shrink-0">
<span
id="home-hall-of-fame"
className="block text-sm font-semibold text-content-muted"
>
명예의 전당
</span>
<span className="mt-2 block text-2xl leading-tight font-extrabold tracking-tight [overflow-wrap:anywhere]">
{FEATURED_TEAM.name}
</span>
<span className="mt-1 flex items-center gap-1 text-xs font-semibold text-content-muted">
<img src={pixelTrophy} alt="" className="lts-hall-pixel size-4" />
직전 멸망전 우승
</span>
</h2>
<div className="h-px bg-line sm:h-auto sm:w-px" aria-hidden="true" />
<ul
className="grid min-w-0 flex-1 gap-1 sm:grid-cols-5 sm:content-center sm:items-start"
aria-label="우승팀 선수"
>
{FEATURED_TEAM.members.map(
({ userId, position, gameName, tagLine, profileIconId }, index) => {
const icon = profileIconUrl(manifest, profileIconId);
const isCaptain = userId === FEATURED_TEAM.captainUserId;
return (
<li key={userId} className="min-w-0">
<Link
to={`/users/${userId}/history?queueGroup=internal`}
className="lts-hall-player group flex h-full items-center gap-2.5 px-2 py-2 transition-colors hover:bg-sunken focus-visible:-outline-offset-2 sm:flex-col sm:gap-2 sm:py-3 sm:text-center"
>
<span className="relative shrink-0">
{isCaptain && (
<img
src={captainCrown}
alt="팀장"
className="lts-hall-crown lts-hall-pixel absolute -top-2.5 -right-2.5 z-10 w-6"
/>
)}
<span
className="lts-hall-portrait relative grid size-10 place-items-center overflow-hidden bg-sunken-strong text-content-muted sm:size-13"
style={{ '--lts-hall-order': index } as CSSProperties}
>
<UserRound className="size-5" aria-hidden="true" />
<img
key={icon}
src={icon}
alt=""
className="absolute inset-0 size-full object-cover"
onError={(event) => {
event.currentTarget.hidden = true;
}}
/>
</span>
</span>
<span className="min-w-0 flex-1 sm:w-full sm:flex-none">
<span className="block text-xs font-semibold text-content-muted">
{positionLabel[position]}
</span>
<span className="flex flex-wrap items-baseline gap-x-1.5 sm:flex-col sm:items-center">
<span className="text-sm font-bold [overflow-wrap:anywhere] group-hover:underline">
{gameName}
</span>
<span className="text-xs text-content-muted [overflow-wrap:anywhere]">
#{tagLine}
</span>
</span>
</span>
<ChevronRight
className="size-4 shrink-0 text-content-muted sm:hidden"
aria-hidden="true"
/>
</Link>
</li>
);
},
)}
</ul>
</div>
{hallOfFame.isPending ? (
<p role="status">명예의 전당을 불러오는 중</p>
) : hallOfFame.isError ? (
<p role="status">
명예의 전당을 불러오지 못했습니다.{' '}
<button type="button" className="underline" onClick={() => void hallOfFame.refetch()}>
다시 시도
</button>
</p>
) : featuredMatch && hallOfFame.data.teams.length > 0 ? (
<div className="space-y-3">
{hallOfFame.data.teams.map((team, index) => (
<FeaturedTeam key={index} team={team} match={featuredMatch} />
))}
</div>
) : (
<p className="text-sm text-content-muted">확정된 멸망전 우승팀이 없습니다.</p>
)}
</section>
);
}
function FeaturedTeam({
team,
match,
}: {
team: HallOfFameResponse['teams'][number];
match: NonNullable<HallOfFameResponse['match']>;
}) {
const { data: manifest } = useDdragonManifest();
const members = [...team.members].sort(
(left, right) =>
(left.position ? POSITION_ORDER.indexOf(left.position) : POSITION_ORDER.length) -
(right.position ? POSITION_ORDER.indexOf(right.position) : POSITION_ORDER.length),
);
return (
<div className="lts-hall-card flex min-w-0 flex-col gap-4 bg-card p-5 sm:flex-row sm:gap-5">
<h2 className="min-w-0 sm:w-36 sm:shrink-0">
<span
className="block text-sm font-semibold text-content-muted"
>
명예의 전당
</span>
<span className="mt-2 block text-2xl leading-tight font-extrabold tracking-tight [overflow-wrap:anywhere]">
{team.name}
</span>
<span className="mt-1 flex items-center gap-1 text-xs font-semibold text-content-muted">
<img src={pixelTrophy} alt="" className="lts-hall-pixel size-4" />
<Link to={`/match/${match.id}`} title={match.title} className="hover:underline">직전 멸망전 우승</Link>
</span>
</h2>
<div className="h-px bg-line sm:h-auto sm:w-px" aria-hidden="true" />
<ul
className="grid min-w-0 flex-1 gap-1 sm:grid-cols-5 sm:content-center sm:items-start"
aria-label="우승팀 선수"
>
{members.map(
({ userId, position, gameName, tagLine, profileIconId }, index) => {
const icon = profileIconId === undefined ? undefined : profileIconUrl(manifest, profileIconId);
const isCaptain = userId === team.captainUserId;
return (
<li key={userId} className="min-w-0">
<Link
to={`/users/${userId}/history?queueGroup=internal`}
className="lts-hall-player group flex h-full items-center gap-2.5 px-2 py-2 transition-colors hover:bg-sunken focus-visible:-outline-offset-2 sm:flex-col sm:gap-2 sm:py-3 sm:text-center"
>
<span className="relative shrink-0">
{isCaptain && (
<img
src={captainCrown}
alt="팀장"
className="lts-hall-crown lts-hall-pixel absolute -top-2.5 -right-2.5 z-10 w-6"
/>
)}
<span
className="lts-hall-portrait relative grid size-10 place-items-center overflow-hidden bg-sunken-strong text-content-muted sm:size-13"
style={{ '--lts-hall-order': index } as CSSProperties}
>
<UserRound className="size-5" aria-hidden="true" />
{icon && <img
key={icon}
src={icon}
alt=""
className="absolute inset-0 size-full object-cover"
onError={(event) => {
event.currentTarget.hidden = true;
}}
/>}
</span>
</span>
<span className="min-w-0 flex-1 sm:w-full sm:flex-none">
<span className="block text-xs font-semibold text-content-muted">
{position ? positionLabel[position] : "포지션 미확인"}
</span>
<span className="flex flex-wrap items-baseline gap-x-1.5 sm:flex-col sm:items-center">
<span className="text-sm font-bold [overflow-wrap:anywhere] group-hover:underline">
{gameName ?? "선수 프로필"}
</span>
<span className="text-xs text-content-muted [overflow-wrap:anywhere]">
{tagLine && `#${tagLine}`}
</span>
</span>
</span>
<ChevronRight
className="size-4 shrink-0 text-content-muted sm:hidden"
aria-hidden="true"
/>
</Link>
</li>
);
},
)}
</ul>
</div>
);
}
@@ -15,6 +15,7 @@ import {
type NormalizedLanePosition,
} from "../lib/internal-game-matchups";
import { ItemIcon, RuneIcon, RuneStyleIcon } from "./ItemTooltip";
import { GameAnalysisNotice } from "./BasicGameScoreboard";
import { Tab, TabList } from "@astryxdesign/core/TabList";
export type InternalGameDetailTab = "scoreboard" | "matchup" | "build";
@@ -992,6 +993,9 @@ export function InternalGameAnalysisPanel({
if (activeTab === "scoreboard") {
return <>{scoreboard}</>;
}
if (selectedGame.analysisAvailability && selectedGame.analysisAvailability !== "available") {
return <GameAnalysisNotice />;
}
if (activeTab === "build") {
return (
@@ -133,6 +133,15 @@ export function CompetitionAdminControls({
queryClient.invalidateQueries({
queryKey: ["matches-page", communityId],
}),
queryClient.invalidateQueries({
queryKey: ["community-internal-stats-matches", communityId],
}),
queryClient.invalidateQueries({
queryKey: ["community-internal-stats-match", communityId, matchId],
}),
queryClient.invalidateQueries({
queryKey: ["hall-of-fame", communityId],
}),
]);
}
@@ -55,7 +55,7 @@ export function TeamTournamentCodes({
return (
<div className="border-t border-base-content/10 px-4 py-5 sm:px-5">
<p role="status" className="text-sm text-content-muted">
이 경기에 배정된 토너먼트 코드가 없습니다.
표시할 세트 정보가 아직 없습니다.
</p>
</div>
);
+2 -2
View File
@@ -36,10 +36,10 @@ export function formatRankBadge(tier: ApiTierInfo | undefined) {
return rank ? `${tierInitial}${rank}` : tierInitial;
}
export function formatRankDetail(tier: ApiTierInfo | undefined) {
export function formatRankDetail(tier: Pick<ApiTierInfo, "tier"> & Partial<Pick<ApiTierInfo, "rank" | "leaguePoints">> | undefined) {
if (!tier) return "랭크 정보 없음";
const tierName = TIER_NAMES[tier.tier] ?? tier.tier;
const rank = normalizeRank(tier.rank);
const label = rank ? `${tierName} ${rank}` : tierName;
return `${label} - ${tier.leaguePoints} LP`;
return tier.leaguePoints === undefined ? label : `${label} - ${tier.leaguePoints} LP`;
}