fix(sf-legacy): фильтр стейл competitors (>1 года Сданные → не конкурент) — Maxim spec #365
1 changed files with 22 additions and 6 deletions
|
|
@ -56,9 +56,21 @@ export function MarketTab({ data }: Props) {
|
|||
data.competitors.length > 0;
|
||||
|
||||
// ── Above-the-fold values ────────────────────────────────────────────────
|
||||
// Note: site_status field pending fix #2/#3 (backend PR). Using total
|
||||
// competitors count as proxy for active (строящихся) count for now.
|
||||
const activeCount = data.competitors.length;
|
||||
// Maxim's spec: «ЖК старше года → не конкурент». Filter active competitors:
|
||||
// - site_status === 'Строящиеся' → активен
|
||||
// - либо ready_dt в будущем → активен (готовность ещё не наступила)
|
||||
// - либо ready_dt в пределах последнего года → активен (свежие продажи)
|
||||
// - иначе (Сданные >1y назад) → не конкурент, скрыт
|
||||
const REL_MS = 365 * 24 * 60 * 60 * 1000;
|
||||
const yearAgoTs = Date.now() - REL_MS;
|
||||
const relevantCompetitors = data.competitors.filter((c) => {
|
||||
if (c.site_status === "Строящиеся") return true;
|
||||
if (!c.ready_dt) return false;
|
||||
const ts = new Date(c.ready_dt).getTime();
|
||||
if (Number.isNaN(ts)) return false;
|
||||
return ts >= yearAgoTs;
|
||||
});
|
||||
const activeCount = relevantCompetitors.length;
|
||||
const radiusKm = getRadiusKm(data);
|
||||
// Treat zero velocity as "no data" — backend returns 0 when competitors
|
||||
// are unmapped to Objective ground truth (OBJ-3). Showing "0.0 м²/мес"
|
||||
|
|
@ -241,11 +253,15 @@ export function MarketTab({ data }: Props) {
|
|||
{/* ── Main content blocks ───────────────────────────────────────────── */}
|
||||
|
||||
{/* Competitors */}
|
||||
{data.competitors.length > 0 && (
|
||||
{relevantCompetitors.length > 0 && (
|
||||
<div>
|
||||
<SectionLabel style={{ marginBottom: 12 }}>Конкуренты</SectionLabel>
|
||||
<SectionLabel style={{ marginBottom: 12 }}>
|
||||
Конкуренты ({relevantCompetitors.length} из{" "}
|
||||
{data.competitors.length}
|
||||
{" — фильтр: строящиеся или сданы ≤1 года)"}
|
||||
</SectionLabel>
|
||||
<CompetitorTable
|
||||
competitors={data.competitors}
|
||||
competitors={relevantCompetitors}
|
||||
districtName={data.district?.district_name}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue