From 237b391dfeeafaef36b1f216cfbfd05862abc0bc Mon Sep 17 00:00:00 2001 From: lekss361 Date: Mon, 18 May 2026 07:14:22 +0300 Subject: [PATCH] fix(sf-legacy): treat velocity=0 as 'no data' in MarketTab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User reports on /legacy/site-finder/[cad]: Велосити 0.0 м²/мес · Срок продаж — which is contradictory — if velocity were truly zero, sales period would be infinity. Root cause: backend returns 0 (not null) when competitors are unmapped to Objective ground truth (OBJ-3). The condition for 'unavailable' must catch both null and zero. Fix: getSalesPeriodMonths already treats velocitySqm <= 0 as null (line 41), but the HeadlineBar + KPI card read raw velocity and display '0.0 м²/мес' for zero. Same coercion applied at the source: velocityPerMonth = (raw != null && raw > 0) ? raw : null. Both HeadlineBar and KPI card now show '—' for zero velocity, matching the '—' shown for Срок продаж. --- frontend/src/components/site-finder/MarketTab.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/site-finder/MarketTab.tsx b/frontend/src/components/site-finder/MarketTab.tsx index 52901e58..d44d4721 100644 --- a/frontend/src/components/site-finder/MarketTab.tsx +++ b/frontend/src/components/site-finder/MarketTab.tsx @@ -60,7 +60,12 @@ export function MarketTab({ data }: Props) { // competitors count as proxy for active (строящихся) count for now. const activeCount = data.competitors.length; const radiusKm = getRadiusKm(data); - const velocityPerMonth = data.velocity?.monthly_velocity_sqm ?? null; + // Treat zero velocity as "no data" — backend returns 0 when competitors + // are unmapped to Objective ground truth (OBJ-3). Showing "0.0 м²/мес" + // is misleading; "—" makes it clear data is unavailable. + const velocityRaw = data.velocity?.monthly_velocity_sqm; + const velocityPerMonth = + velocityRaw != null && velocityRaw > 0 ? velocityRaw : null; const maxMixPct = getMaxMixPct(data); const salesPeriodMonths = getSalesPeriodMonths(data);