release/86 #2

Merged
dahyeon merged 108 commits from release/86 into main 2026-07-15 08:56:05 +00:00
9 changed files with 156 additions and 206 deletions
Showing only changes of commit 0434a5db66 - Show all commits

No files matched your search

@@ -33,6 +33,7 @@ function record(matchId: mongoose.Types.ObjectId): InternalRecord {
gameDuration: 1_800,
userId: new mongoose.Types.ObjectId().toString(),
summonerName: 'Player',
tagLine: 'KR1',
profileIconId: 1,
teamIndex: 1,
side: 'blue',
@@ -186,7 +187,7 @@ describe('CommunityStatsService', () => {
});
expect(matchStatsService.buildAndUpsert).not.toHaveBeenCalled();
expect(cacheService.setDetail).toHaveBeenCalledWith(
expect.stringContaining(':r2:'),
expect.stringContaining(':r3:'),
response,
);
});
@@ -36,7 +36,7 @@ const DEFAULT_LIST_LIMIT = 20;
const MAX_LIST_LIMIT = 50;
const MAX_MATCH_SCAN = 300;
const MIN_HIGHLIGHT_GAMES = 5;
const MATCH_DETAIL_RESPONSE_CACHE_VERSION = 2;
const MATCH_DETAIL_RESPONSE_CACHE_VERSION = 3;
interface CommunityStatsContext {
community: CommunityDocument;
@@ -248,6 +248,7 @@ export class CommunityStatsService {
participants: team.participants.map((record) => ({
userId: record.userId,
summonerName: record.summonerName,
tagLine: record.tagLine,
teamIndex: record.teamIndex,
side: record.side,
teamPosition: record.teamPosition,
@@ -1027,6 +1028,7 @@ function isCompleteMatchDetailResponse(
Array.isArray(team.bans) &&
team.participants.every(
(participant) =>
typeof participant.tagLine === 'string' &&
Array.isArray(participant.itemBuild) &&
Array.isArray(participant.skillBuild),
),
@@ -145,6 +145,7 @@ export interface InternalMatchDetailResponse {
participants: Array<{
userId: string | null;
summonerName: string;
tagLine: string;
teamIndex: number;
side: TeamSide;
teamPosition: string;
@@ -325,6 +325,7 @@ export class MatchStatsFragmentBuilder {
rawParticipant?.riotIdGameName ??
rawParticipant?.summonerName ??
'Unknown',
tagLine: snapshot?.tagLine ?? rawParticipant?.riotIdTagLine ?? '',
profileIconId: snapshot?.profileIconId ?? 0,
teamIndex: participant.teamIndex,
side: participant.side,
@@ -114,7 +114,7 @@ describe('MatchStatsService', () => {
scheduledAt,
gameCreationMin: 1_000,
gameCreationMax: 2_000,
builderVersion: 8,
builderVersion: 9,
}),
);
});
@@ -4,7 +4,7 @@ import type {
} from '../global/database/schema';
import type { InternalMatchCardView } from './community-stats.types';
export const MATCH_STATS_BUILDER_VERSION = 8;
export const MATCH_STATS_BUILDER_VERSION = 9;
export type InternalRecord = MatchStatsRecord;
export type InternalGameDetail = MatchStatsGameDetail;
@@ -711,6 +711,7 @@ export interface MatchStatsRecord {
gameDuration: number;
userId: string;
summonerName: string;
tagLine: string;
profileIconId: number;
teamIndex: number;
side: TeamSide;
+1
View File
@@ -796,6 +796,7 @@ export interface ApiInternalMatchDetailResponse {
participants: Array<{
userId: string | null;
summonerName: string;
tagLine: string;
teamIndex: number;
side: TeamSide;
teamPosition: string;
+145 -202
View File
@@ -35,20 +35,13 @@ type MatchGameTeam = MatchGameDetail["teams"][number];
type MatchGameParticipant = MatchGameTeam["participants"][number];
type DdragonManifestData = ReturnType<typeof useDdragonManifest>["data"];
type RuneStyleEntry = NonNullable<DdragonManifestData>["runesReforged"][number];
type DetailTab =
| "scoreboard"
| "matchup"
| "build"
| "damageDealt"
| "damageTaken";
type DetailTab = "scoreboard" | "matchup" | "build";
type TimelineMetric = "gold" | "xp";
const DETAIL_TABS: Array<{ id: DetailTab; label: string }> = [
{ id: "scoreboard", label: "스코어보드" },
{ id: "matchup", label: "라인전" },
{ id: "build", label: "룬 / 빌드" },
{ id: "damageDealt", label: "가한 데미지" },
{ id: "damageTaken", label: "받은 데미지" },
];
const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [
@@ -154,9 +147,18 @@ function teamTotals(team: MatchGameTeam) {
assists: totals.assists + participant.assists,
gold: totals.gold + participant.gold,
damage: totals.damage + participant.damageDealtToChampions,
damageTaken: totals.damageTaken + (participant.damageTaken ?? 0),
vision: totals.vision + participant.visionScore,
}),
{ kills: 0, deaths: 0, assists: 0, gold: 0, damage: 0, vision: 0 },
{
kills: 0,
deaths: 0,
assists: 0,
gold: 0,
damage: 0,
damageTaken: 0,
vision: 0,
},
);
}
@@ -211,25 +213,6 @@ function runeStyleSelection(
return participant.perks.styles?.find((style) => style.styleId === styleId);
}
function StatBlock({
label,
value,
}: {
label: string;
value: string | number;
}) {
return (
<div className="border border-base-content/8 bg-base-100 px-3 py-2">
<div className="text-xs font-black uppercase tracking-wider text-base-content/35">
{label}
</div>
<div className="mt-1 text-sm font-black tabular-nums text-base-content">
{value}
</div>
</div>
);
}
function WinBadge({ win }: { win: boolean }) {
return win ? (
<span className="inline-flex items-center border border-accent/60 bg-accent px-2 py-0.5 text-xs font-black text-accent-content">
@@ -301,7 +284,7 @@ function SpellRuneStrip({
{[0, 1].map((index) => (
<span
key={`spell-${index}`}
className="h-4 w-4 overflow-hidden bg-base-content/10"
className="h-5 w-5 overflow-hidden bg-base-content/10"
>
{spellIcons[index] ? (
<img
@@ -317,7 +300,7 @@ function SpellRuneStrip({
{[0, 1].map((index) => (
<span
key={`rune-${index}`}
className="h-4 w-4 overflow-hidden bg-base-content/10"
className="h-5 w-5 overflow-hidden bg-base-content/10"
>
{runeIcons[index] ? (
<img
@@ -373,43 +356,88 @@ function PercentBar({ value, side }: { value: number; side: TeamSide }) {
);
}
function PlayerRow({
function PlayerIdentityCell({
participant,
manifest,
avatarSize = "h-12 w-12",
nameMaxWidth = "max-w-[150px]",
}: {
participant: MatchGameParticipant;
manifest: ReturnType<typeof useDdragonManifest>["data"];
avatarSize?: string;
nameMaxWidth?: string;
}) {
const location = useLocation();
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
const lane =
LANE_LABELS[participant.teamPosition] ?? participant.teamPosition ?? "-";
const nameNode = (
<>
{participant.summonerName}
{participant.tagLine ? (
<span className="font-normal text-base-content/30">
{" "}
#{participant.tagLine}
</span>
) : null}
</>
);
return (
<tr className="border-t border-base-content/5 hover:bg-base-content/[0.02]">
<td className="px-3 py-2.5">
<ChampionCell participant={participant} manifest={manifest} />
</td>
<td className="px-3 py-2.5">
<SpellRuneStrip participant={participant} manifest={manifest} />
</td>
<td className="px-3 py-2.5">
<div className="flex min-w-0 items-center gap-2">
<ChampionAvatar
participant={participant}
manifest={manifest}
size={avatarSize}
/>
<SpellRuneStrip participant={participant} manifest={manifest} />
<div className="min-w-0">
{participant.userId ? (
<Link
to={`/users/${participant.userId}/history?queueGroup=internal`}
state={{ backTo: historyBackTo }}
className="block max-w-[170px] truncate text-sm font-bold text-base-content hover:text-primary"
className={`block ${nameMaxWidth} truncate text-sm font-bold text-base-content hover:text-primary`}
>
{participant.summonerName}
{nameNode}
</Link>
) : (
<span className="block max-w-[170px] truncate text-sm font-bold text-base-content">
{participant.summonerName}
</span>
)}
{(participant.firstBloodKill || participant.firstBloodAssist) && (
<span className="mt-1 inline-flex border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 text-[10px] font-black text-amber-400">
{participant.firstBloodKill ? "FB" : "FBA"}
<span
className={`block ${nameMaxWidth} truncate text-sm font-bold text-base-content`}
>
{nameNode}
</span>
)}
<div className="mt-0.5 flex items-center gap-1.5">
<span className="text-xs text-base-content/35">{lane}</span>
{(participant.firstBloodKill || participant.firstBloodAssist) && (
<span className="inline-flex border border-amber-400/30 bg-amber-400/10 px-1 text-[10px] font-black text-amber-400">
{participant.firstBloodKill ? "FB" : "FBA"}
</span>
)}
</div>
</div>
</div>
);
}
function PlayerRow({
participant,
manifest,
teamDamageTaken,
}: {
participant: MatchGameParticipant;
manifest: ReturnType<typeof useDdragonManifest>["data"];
teamDamageTaken: number;
}) {
const takenShare =
teamDamageTaken > 0
? ((participant.damageTaken ?? 0) / teamDamageTaken) * 100
: 0;
return (
<tr className="border-t border-base-content/5 hover:bg-base-content/[0.02]">
<td className="px-3 py-2.5">
<PlayerIdentityCell participant={participant} manifest={manifest} />
</td>
<td className="px-3 py-2.5 text-center">
<div className="text-sm font-black tabular-nums text-base-content">
@@ -425,11 +453,13 @@ function PlayerRow({
participant.deaths,
participant.assists,
)}
{participant.deaths === 0 ? "" : " KDA"}
<span className="ml-1 text-base-content/35">
({participant.killParticipation}%)
</span>
</div>
</td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums text-base-content/60">
{formatCompactNumber(participant.damageDealtToChampions)}
{formatNumber(participant.damageDealtToChampions)}
<div className="mx-auto w-16">
<PercentBar value={participant.damageShare} side={participant.side} />
</div>
@@ -437,6 +467,13 @@ function PlayerRow({
{formatPercent(participant.damageShare)}
</span>
</td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums text-base-content/60">
{formatNumber(participant.damageTaken ?? 0)}
<div className="mx-auto w-16">
<PercentBar value={takenShare} side={participant.side} />
</div>
<span className="text-base-content/35">{Math.round(takenShare)}%</span>
</td>
<td className="px-3 py-2.5 text-center text-xs tabular-nums text-base-content/60">
{participant.visionScore}
<span className="block text-base-content/35">
@@ -462,18 +499,22 @@ function PlayerRow({
function PlayerCard({
participant,
manifest,
teamDamageTaken,
}: {
participant: MatchGameParticipant;
manifest: ReturnType<typeof useDdragonManifest>["data"];
teamDamageTaken: number;
}) {
const location = useLocation();
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
const takenShare =
teamDamageTaken > 0
? ((participant.damageTaken ?? 0) / teamDamageTaken) * 100
: 0;
return (
<div className="p-3">
<div className="flex items-start gap-2">
<ChampionCell participant={participant} manifest={manifest} />
<div className="ml-auto shrink-0 text-right">
<div className="flex items-start justify-between gap-2">
<PlayerIdentityCell participant={participant} manifest={manifest} />
<div className="shrink-0 text-right">
<div className="text-sm font-black tabular-nums text-base-content">
{participant.kills}
<span className="text-base-content/25"> / </span>
@@ -487,49 +528,40 @@ function PlayerCard({
participant.deaths,
participant.assists,
)}
{participant.deaths === 0 ? "" : " KDA"}
<span className="ml-1 text-base-content/35">
({participant.killParticipation}%)
</span>
</div>
</div>
</div>
<div className="mt-2 flex items-center justify-between gap-2">
<div className="flex min-w-0 items-center gap-2">
{participant.userId ? (
<Link
to={`/users/${participant.userId}/history?queueGroup=internal`}
state={{ backTo: historyBackTo }}
className="block max-w-[160px] truncate text-sm font-bold text-base-content hover:text-primary"
>
{participant.summonerName}
</Link>
) : (
<span className="block max-w-[160px] truncate text-sm font-bold text-base-content">
{participant.summonerName}
</span>
)}
{(participant.firstBloodKill || participant.firstBloodAssist) && (
<span className="inline-flex border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 text-[10px] font-black text-amber-400">
{participant.firstBloodKill ? "FB" : "FBA"}
</span>
)}
</div>
<SpellRuneStrip participant={participant} manifest={manifest} />
</div>
<div className="mt-2">
<ItemStrip participant={participant} manifest={manifest} />
</div>
<div className="mt-2 grid grid-cols-3 gap-2 text-[11px] tabular-nums">
<div className="mt-2 grid grid-cols-2 gap-2 text-[11px] tabular-nums sm:grid-cols-4">
<div className="border border-base-content/8 px-2 py-1.5">
<div className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
피해량
가한 피해량
</div>
<div className="mt-0.5 font-black text-base-content/70">
{formatCompactNumber(participant.damageDealtToChampions)}
{formatNumber(participant.damageDealtToChampions)}
<span className="ml-1 font-bold text-base-content/35">
{formatPercent(participant.damageShare)}
</span>
</div>
<PercentBar value={participant.damageShare} side={participant.side} />
</div>
<div className="border border-base-content/8 px-2 py-1.5">
<div className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
받은 피해량
</div>
<div className="mt-0.5 font-black text-base-content/70">
{formatNumber(participant.damageTaken ?? 0)}
<span className="ml-1 font-bold text-base-content/35">
{Math.round(takenShare)}%
</span>
</div>
<PercentBar value={takenShare} side={participant.side} />
</div>
<div className="border border-base-content/8 px-2 py-1.5">
<div className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
CS
@@ -596,16 +628,23 @@ function TeamScoreHeader({
</div>
</div>
</div>
<div className="grid grid-cols-3 gap-2 sm:grid-cols-6 lg:min-w-[520px]">
<StatBlock label="K" value={totals.kills} />
<StatBlock label="D" value={totals.deaths} />
<StatBlock label="A" value={totals.assists} />
<StatBlock label="Gold" value={formatCompactNumber(totals.gold)} />
<StatBlock
label="Damage"
value={formatCompactNumber(totals.damage)}
/>
<StatBlock label="Vision" value={totals.vision} />
<div className="flex shrink-0 items-center gap-4 text-sm font-black tabular-nums">
<div className="flex items-baseline gap-1.5">
<span className="text-[10px] font-bold uppercase tracking-wider text-base-content/35">
KDA
</span>
<span className="text-base-content">
{totals.kills} / {totals.deaths} / {totals.assists}
</span>
</div>
<div className="flex items-baseline gap-1.5">
<span className="text-[10px] font-bold uppercase tracking-wider text-base-content/35">
Gold
</span>
<span className="text-base-content">
{formatCompactNumber(totals.gold)}
</span>
</div>
</div>
</div>
</div>
@@ -1019,6 +1058,8 @@ function TeamTable({
detail: ApiInternalMatchDetailResponse;
manifest: ReturnType<typeof useDdragonManifest>["data"];
}) {
const teamDamageTaken = teamTotals(team).damageTaken;
return (
<section className="overflow-hidden border border-base-content/10 bg-base-100">
<TeamScoreHeader team={team} detail={detail} />
@@ -1028,19 +1069,19 @@ function TeamTable({
key={`card-${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`}
participant={participant}
manifest={manifest}
teamDamageTaken={teamDamageTaken}
/>
))}
</div>
<div className="hidden overflow-x-auto lg:block">
<table className="w-full min-w-[1080px] table-fixed text-left">
<table className="w-full min-w-[1040px] table-fixed text-left">
<thead>
<tr className="bg-base-content/[0.02] text-xs uppercase tracking-wider text-base-content/35">
<th className="w-[196px] px-3 py-2.5">챔피언</th>
<th className="w-[60px] px-3 py-2.5">스펠/룬</th>
<th className="w-[160px] px-3 py-2.5">선수</th>
<th className="w-[112px] px-3 py-2.5 text-center">KDA</th>
<th className="w-[124px] px-3 py-2.5 text-center">피해량</th>
<th className="w-[92px] px-3 py-2.5 text-center">시야</th>
<th className="w-[276px] px-3 py-2.5">선수</th>
<th className="w-[108px] px-3 py-2.5 text-center">KDA</th>
<th className="w-[120px] px-3 py-2.5 text-center">가한 피해량</th>
<th className="w-[120px] px-3 py-2.5 text-center">받은 피해량</th>
<th className="w-[80px] px-3 py-2.5 text-center">시야</th>
<th className="w-[76px] px-3 py-2.5 text-center">CS</th>
<th className="w-[260px] px-3 py-2.5">아이템</th>
</tr>
@@ -1051,6 +1092,7 @@ function TeamTable({
key={`${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`}
participant={participant}
manifest={manifest}
teamDamageTaken={teamDamageTaken}
/>
))}
</tbody>
@@ -1550,83 +1592,6 @@ function SkillBuildPanel({
);
}
function DamagePanel({
selectedGame,
detail,
manifest,
metric,
}: {
selectedGame: MatchGameDetail;
detail: ApiInternalMatchDetailResponse;
manifest: ReturnType<typeof useDdragonManifest>["data"];
metric: "dealt" | "taken";
}) {
const participants = selectedGame.teams.flatMap((team) => team.participants);
const maxValue = Math.max(
1,
...participants.map((participant) =>
metric === "dealt"
? participant.damageDealtToChampions
: (participant.damageTaken ?? 0),
),
);
const orderedTeams = [...selectedGame.teams].sort((left, right) =>
left.side === right.side ? 0 : left.side === "blue" ? -1 : 1,
);
return (
<section className="grid gap-4 lg:grid-cols-2">
{orderedTeams.map((team) => {
const tone = sideTone(team.side);
return (
<div
key={`${team.side}-${metric}`}
className="overflow-hidden border border-base-content/10 bg-base-100"
>
<div
className={`border-b border-base-content/8 px-4 py-3 ${tone.bg}`}
>
<div className={`text-sm font-black ${tone.text}`}>
{getTeamName(detail, team.teamIndex)} · {sideLabel(team.side)}
</div>
</div>
<div className="overflow-x-auto">
<div className="min-w-[520px] divide-y divide-base-content/5">
{team.participants.map((participant) => {
const value =
metric === "dealt"
? participant.damageDealtToChampions
: (participant.damageTaken ?? 0);
return (
<div
key={`${metric}-${participant.userId ?? participant.summonerName}-${participant.championId}`}
className="grid grid-cols-[220px_1fr_72px] items-center gap-3 px-4 py-3 text-xs"
>
<ChampionCell
participant={participant}
manifest={manifest}
/>
<div className="h-2 bg-base-content/8">
<div
className={`h-full ${tone.bar}`}
style={{ width: barWidth(value, maxValue) }}
/>
</div>
<div className="text-right font-black tabular-nums text-base-content/70">
{formatNumber(value)}
</div>
</div>
);
})}
</div>
</div>
</div>
);
})}
</section>
);
}
const LANE_SORT_ORDER = ["TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY"];
function laneSortValue(position: string) {
@@ -1755,16 +1720,16 @@ function LaneMatchupCard({
label: "골드",
blueValue: blue.gold,
redValue: red.gold,
blueText: formatCompactNumber(blue.gold),
redText: formatCompactNumber(red.gold),
blueText: formatNumber(blue.gold),
redText: formatNumber(red.gold),
},
{
key: "damage",
label: "딜량",
blueValue: blue.damageDealtToChampions,
redValue: red.damageDealtToChampions,
blueText: formatCompactNumber(blue.damageDealtToChampions),
redText: formatCompactNumber(red.damageDealtToChampions),
blueText: formatNumber(blue.damageDealtToChampions),
redText: formatNumber(red.damageDealtToChampions),
},
{
key: "cs",
@@ -1947,28 +1912,6 @@ function GameAnalysisPanel({
);
}
if (activeTab === "damageDealt") {
return (
<DamagePanel
selectedGame={selectedGame}
detail={detail}
manifest={manifest}
metric="dealt"
/>
);
}
if (activeTab === "damageTaken") {
return (
<DamagePanel
selectedGame={selectedGame}
detail={detail}
manifest={manifest}
metric="taken"
/>
);
}
return (
<LaneMatchupPanel
selectedGame={selectedGame}