From b98a438843cb69becc93d26b330d1ed45012dc63 Mon Sep 17 00:00:00 2001 From: 0xYYBB | ZYY | Bobo <128128010+zhouyongyou@users.noreply.github.com> Date: Fri, 7 Nov 2025 09:35:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20prevent=20NaN%=20display=20in=20com?= =?UTF-8?q?petition=20gap=20calculation=20(#633)=20(#670)=20**Problem:**?= =?UTF-8?q?=20Competition=20page=20shows=20"NaN%"=20for=20gap=20difference?= =?UTF-8?q?=20when=20trader=20P&L=20percentages=20are=20null/undefined.=20?= =?UTF-8?q?**Root=20Cause:**=20Line=20227:=20`const=20gap=20=3D=20trader.t?= =?UTF-8?q?otal=5Fpnl=5Fpct=20-=20opponent.total=5Fpnl=5Fpct`=20-=20If=20e?= =?UTF-8?q?ither=20value=20is=20`undefined`=20or=20`null`,=20result=20is?= =?UTF-8?q?=20`NaN`=20-=20Display=20shows=20"=E9=A2=86=E5=85=88=20NaN%"=20?= =?UTF-8?q?or=20"=E8=90=BD=E5=90=8E=20NaN%"=20**Solution:**=20Add=20null?= =?UTF-8?q?=20coalescing=20to=20default=20undefined/null=20values=20to=200?= =?UTF-8?q?:=20```typescript=20const=20gap=20=3D=20(trader.total=5Fpnl=5Fp?= =?UTF-8?q?ct=20=3F=3F=200)=20-=20(opponent.total=5Fpnl=5Fpct=20=3F=3F=200?= =?UTF-8?q?)=20```=20**Impact:**=20-=20=E2=9C=85=20Gap=20calculation=20ret?= =?UTF-8?q?urns=200=20when=20data=20is=20missing=20(shows=200.00%)=20-=20?= =?UTF-8?q?=E2=9C=85=20Prevents=20confusing=20"NaN%"=20display=20-=20?= =?UTF-8?q?=E2=9C=85=20Graceful=20degradation=20for=20incomplete=20data=20?= =?UTF-8?q?Fixes=20#633=20Co-authored-by:=20tinkle-community=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/CompetitionPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/CompetitionPage.tsx b/web/src/components/CompetitionPage.tsx index 2c1effd2..b9d1946e 100644 --- a/web/src/components/CompetitionPage.tsx +++ b/web/src/components/CompetitionPage.tsx @@ -392,7 +392,7 @@ export function CompetitionPage() { {sortedTraders.map((trader, index) => { const isWinning = index === 0 const opponent = sortedTraders[1 - index] - const gap = trader.total_pnl_pct - opponent.total_pnl_pct + const gap = (trader.total_pnl_pct ?? 0) - (opponent.total_pnl_pct ?? 0) return (