fix(site-finder): unique factor key (X1 #47) — prevent React collision
PR #87 auto-review нашёл: два POI одной категории на одинаковом округлённом
расстоянии (например two аптеки 450м в плотном районе центра ЕКБ) давали
duplicate factor key "pharmacy_450m" → silent React reconciliation errors.
Fix: добавил enumerate index в slug: f"{cat}_{round(distance_m)}m_{idx}".
1 строка, backward compat (factor — opaque slug, не парсится клиентом).
Per auto-review on 97dc4ba.
This commit is contained in:
parent
b5a218160d
commit
ec681441e5
1 changed files with 5 additions and 2 deletions
|
|
@ -802,7 +802,7 @@ def analyze_parcel(
|
|||
by_category: dict[str, list[dict[str, Any]]] = {}
|
||||
# X1 (#47): per-POI breakdown с verbal explain для UI
|
||||
factors_detailed: list[dict[str, Any]] = []
|
||||
for p in poi_rows:
|
||||
for idx, p in enumerate(poi_rows):
|
||||
cat: str = p["category"]
|
||||
w = _POI_WEIGHTS.get(cat, 0.0)
|
||||
# distance decay: 1.0 на 0м, 0.5 на ~500м, ~0 на 1000м
|
||||
|
|
@ -826,7 +826,10 @@ def analyze_parcel(
|
|||
continue
|
||||
factors_detailed.append(
|
||||
{
|
||||
"factor": f"{cat}_{round(distance_m)}m",
|
||||
# Include idx чтобы избежать React key collision: два POI одной
|
||||
# категории на одинаково округлённом расстоянии иначе дали бы
|
||||
# дубль (например, two аптеки 450м в плотном районе).
|
||||
"factor": f"{cat}_{round(distance_m)}m_{idx}",
|
||||
"category": cat,
|
||||
"category_ru": _POI_CATEGORY_RU.get(cat, cat),
|
||||
"group": _POI_GROUP.get(cat, "Прочее"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue