Show all metric insights with descriptions

This commit is contained in:
dahyeon committed 2026-07-03 02:44:00 -07:00
1 parent 741fce0adb
commit cfbc74d882
9 files changed
+171 -33

No files matched your search

@@ -144,15 +144,25 @@ describe('AnalysisReadService', () => {
(metric) => metric.metricId === 'deathWithShutdownBountyGivenRate',
),
).toBe(false);
expect(analysis.strengths).toEqual([
expect(analysis.strengths).toHaveLength(12);
expect(analysis.weaknesses).toHaveLength(12);
expect(analysis.strengths.slice(0, 3)).toEqual([
{ metricId: 'deathsPerMin', value: 0.1 },
{ metricId: 'kda', value: 0.8 },
{ metricId: 'killParticipation', value: 0.7 },
]);
expect(analysis.weaknesses).toEqual([
expect(analysis.strengths.at(-1)).toEqual({
metricId: 'wardsKilledPerMin',
value: 0.1,
});
expect(analysis.weaknesses.slice(0, 3)).toEqual([
{ metricId: 'wardsKilledPerMin', value: 0.1 },
{ metricId: 'visionScorePerMin', value: 0.2 },
{ metricId: 'controlWardsPlaced', value: 0.2 },
]);
expect(analysis.weaknesses.at(-1)).toEqual({
metricId: 'deathsPerMin',
value: 0.1,
});
});
});
@@ -201,7 +201,6 @@ export class AnalysisReadService {
? right.score - left.score
: left.score - right.score,
)
.slice(0, 3)
.map(({ metricId, value }) => ({ metricId, value }));
}
+2 -1
View File
@@ -185,7 +185,8 @@ describe('shared feature registry', () => {
expect(new Set(metricIds).size).toBe(metricIds.length);
for (const metric of METRICS) {
expect(metric.label).toBeTruthy();
expect(metric.label.trim()).toBeTruthy();
expect(metric.description.trim()).toBeTruthy();
expect(metric.baseline).toBeDefined();
expect(Object.keys(metric.baseline ?? {}).sort()).toEqual([
'BOTTOM',
+25 -7
View File
@@ -353,7 +353,7 @@ describe('AppController (e2e)', () => {
queueId: 420,
featureSchemaVersion: FEATURE_SCHEMA_VERSION,
});
expect(responseBody).toEqual({
expect(responseBody).toMatchObject({
account: {
gameName: 'Hide on bush',
profileIconId: 1,
@@ -392,18 +392,36 @@ describe('AppController (e2e)', () => {
queueId: 420,
sampleGameCount: 12,
},
strengths: [
updatedAt: '2026-07-02T00:00:00.000Z',
});
expect(responseBody.strengths).toHaveLength(12);
expect(responseBody.weaknesses).toHaveLength(12);
expect(responseBody.strengths).toEqual(
expect.arrayContaining([
{ metricId: 'deathsPerMin', value: 0.1 },
{ metricId: 'kda', value: 0.8 },
{ metricId: 'killParticipation', value: 0.7 },
],
weaknesses: [
{ metricId: 'wardsKilledPerMin', value: 0.1 },
]),
);
expect(responseBody.weaknesses).toEqual(
expect.arrayContaining([
{ metricId: 'wardsKilledPerMin', value: 0.1 },
{ metricId: 'visionScorePerMin', value: 0.2 },
{ metricId: 'controlWardsPlaced', value: 0.2 },
],
updatedAt: '2026-07-02T00:00:00.000Z',
});
{ metricId: 'deathsPerMin', value: 0.1 },
]),
);
expect(responseBody.strengths.slice(0, 3)).toEqual([
{ metricId: 'deathsPerMin', value: 0.1 },
{ metricId: 'kda', value: 0.8 },
{ metricId: 'killParticipation', value: 0.7 },
]);
expect(responseBody.weaknesses.slice(0, 3)).toEqual([
{ metricId: 'wardsKilledPerMin', value: 0.1 },
{ metricId: 'visionScorePerMin', value: 0.2 },
{ metricId: 'controlWardsPlaced', value: 0.2 },
]);
});
it('/api/players/:puuid/analysis/latest (GET) returns 404 without a profile', async () => {
+34 -13
View File
@@ -361,36 +361,58 @@
.metric-card-list {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-columns: 1fr;
gap: 10px;
margin-top: 16px;
}
.metric-card {
min-width: 0;
min-height: 94px;
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 12px;
display: grid;
gap: 8px;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--surface-soft);
padding: 14px;
}
.metric-card span {
color: var(--text-muted);
font-size: 13px;
.metric-card-heading {
min-width: 0;
display: flex;
align-items: start;
justify-content: space-between;
gap: 12px;
}
.metric-card-heading h3 {
min-width: 0;
margin: 0;
font-size: 15px;
line-height: 1.35;
}
.metric-card strong {
.metric-card-heading strong {
flex: 0 0 auto;
color: var(--text-strong);
font-size: 24px;
font-size: 22px;
line-height: 1;
}
.metric-card p {
margin: 0;
color: var(--text-muted);
font-size: 13px;
line-height: 1.45;
}
.metric-card > span {
color: var(--text-muted);
font-size: 12px;
font-weight: 700;
line-height: 1.35;
text-transform: uppercase;
}
.champion-list {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -640,8 +662,7 @@
min-height: auto;
}
.summary-stat-grid,
.metric-card-list {
.summary-stat-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
+28 -1
View File
@@ -1,4 +1,9 @@
import { METRICS, type MetricId, type Role } from '@persona-lenz/shared';
import {
METRICS,
type MetricDefinition,
type MetricId,
type Role,
} from '@persona-lenz/shared';
export const ROLE_LABELS: Record<Role, string> = {
BOTTOM: '원딜',
@@ -22,6 +27,9 @@ export const STAGE_LABELS: Record<string, string> = {
const metricLabelById = new Map<MetricId, string>(
METRICS.map((metric) => [metric.id, metric.label]),
);
const metricDefinitionById = new Map<MetricId, MetricDefinition>(
METRICS.map((metric) => [metric.id, metric]),
);
export function formatPercent(value: number): string {
return `${Math.round(value * 100)}%`;
@@ -31,6 +39,25 @@ export function getMetricLabel(metricId: MetricId): string {
return metricLabelById.get(metricId) ?? metricId;
}
export function getMetricDescription(metricId: MetricId): string {
return (
metricDefinitionById.get(metricId)?.description ??
'정규화된 플레이스타일 지표입니다.'
);
}
export function getMetricDirectionLabel(metricId: MetricId): string {
const direction = metricDefinitionById.get(metricId)?.direction;
if (direction === 'lowerIsBetter') {
return '낮을수록 좋음';
}
if (direction === 'higherIsBetter') {
return '높을수록 좋음';
}
return '참고 지표';
}
export function getStageLabel(stage?: string): string {
if (!stage) {
return '작업 상태 확인';
+27 -5
View File
@@ -33,6 +33,8 @@ import {
import {
formatPercent,
formatTier,
getMetricDescription,
getMetricDirectionLabel,
getMetricLabel,
ROLE_LABELS,
} from '../lib/format';
@@ -251,8 +253,16 @@ export function DashboardPage() {
</section>
<section className="insight-grid" aria-label="강점과 약점">
<MetricInsightList title="강점 Top 3" values={analysis.strengths} />
<MetricInsightList title="약점 Top 3" values={analysis.weaknesses} />
<MetricInsightList
description="방향성을 반영했을 때 현재 프로필에서 상대적으로 좋은 순서입니다."
title="강점 지표"
values={analysis.strengths}
/>
<MetricInsightList
description="방향성을 반영했을 때 개선 여지가 큰 순서입니다."
title="약점 지표"
values={analysis.weaknesses}
/>
</section>
<section className="champion-section" aria-labelledby="champion-title">
@@ -310,20 +320,32 @@ function SummaryStat({ label, value }: { label: string; value: string }) {
}
function MetricInsightList({
description,
title,
values,
}: {
description: string;
title: string;
values: MetricValueDto[];
}) {
return (
<section className="insight-section">
<h2>{title}</h2>
<div className="section-heading">
<div>
<h2>{title}</h2>
<p className="section-copy">{description}</p>
</div>
<span className="status-pill">{values.length} metrics</span>
</div>
<div className="metric-card-list">
{values.map((metricValue) => (
<article className="metric-card" key={metricValue.metricId}>
<span>{getMetricLabel(metricValue.metricId)}</span>
<strong>{formatPercent(metricValue.value)}</strong>
<div className="metric-card-heading">
<h3>{getMetricLabel(metricValue.metricId)}</h3>
<strong>{formatPercent(metricValue.value)}</strong>
</div>
<p>{getMetricDescription(metricValue.metricId)}</p>
<span>{getMetricDirectionLabel(metricValue.metricId)}</span>
</article>
))}
</div>