fix(site-finder): normalize POI weighted score to 0..100 on backend (#1486) #1674

Merged
lekss361 merged 2 commits from fix/poi-score-scale-1486 into main 2026-06-17 17:54:53 +00:00
3 changed files with 31 additions and 32 deletions
Showing only changes of commit b534579e1b - Show all commits

View file

@ -373,6 +373,7 @@ def test_routing_decay_empty_db(monkeypatch):
monkeypatch.setattr(ors_client, "is_configured", lambda: True)
result = compute_poi_routing_decay(db, "cad", 56.838, 60.605)
assert result.top_poi == []
assert result.poi_weighted_score == 0.0
def test_routing_decay_score_spread_wider_than_straight_line(monkeypatch):

View file

@ -72,10 +72,8 @@ interface Props {
// ── Component ─────────────────────────────────────────────────────────────────
export function PoiList2Gis({ items, totalScore }: Props) {
// POI-weighted score is presented as «X / 100», so clamp to 0..100 defensively:
// the adapter sums round(weight*100) per POI без нормировки и при достаточном
// числе POI может выдать >100 → бессмысленное «137 / 100» (#1470). Корневую
// нормировку нужно чинить в site-finder-api.ts (useParcelPoiScoreQuery).
// poi_weighted_score is normalized to 0..100 on the backend (#1486).
// Clamp defensively in case of floating-point edge cases.
const displayScore = Math.min(100, Math.max(0, totalScore));
// Top-7, sorted by score_contribution desc

View file

@ -1,22 +1,22 @@
{
"cad_num": "66:41:0701045:42",
"radius_m": 2000,
"poi_weighted_score": 72,
"top_poi": [
"poi_weighted_score": 19.9,
"items": [
{
"category": "park",
"name": "Сквер Попова",
"distance_m": 150,
"weight": 0.014,
"score_contribution": 4.4,
"address": null
},
{
"category": "metro_stop",
"name": "Площадь 1905 года",
"distance_m": 340,
"weight": 0.013559,
"score_contribution": 22.3,
"address": null
},
{
"category": "school",
"name": "Школа № 32",
"distance_m": 480,
"weight": 0.00885,
"score_contribution": 14.5,
"weight": 0.013636,
"score_contribution": 4.3,
"address": null
},
{
@ -24,15 +24,15 @@
"name": "Детский сад № 111",
"distance_m": 260,
"weight": 0.0125,
"score_contribution": 12.7,
"score_contribution": 4.0,
"address": null
},
{
"category": "park",
"name": "Сквер Попова",
"distance_m": 150,
"weight": 0.014,
"score_contribution": 10.8,
"category": "school",
"name": "Школа № 32",
"distance_m": 480,
"weight": 0.008621,
"score_contribution": 2.7,
"address": null
},
{
@ -40,15 +40,7 @@
"name": "Городская больница № 7",
"distance_m": 650,
"weight": 0.005333,
"score_contribution": 8.8,
"address": null
},
{
"category": "shop_mall",
"name": "МЕГА Екатеринбург",
"distance_m": 1200,
"weight": 0.003077,
"score_contribution": 5.0,
"score_contribution": 1.7,
"address": null
},
{
@ -56,7 +48,15 @@
"name": "Гимназия № 9",
"distance_m": 820,
"weight": 0.005435,
"score_contribution": 4.4,
"score_contribution": 1.7,
"address": null
},
{
"category": "shop_mall",
"name": "МЕГА Екатеринбург",
"distance_m": 1200,
"weight": 0.003077,
"score_contribution": 1.0,
"address": null
}
]