diff --git a/backend/routers/analyze.py b/backend/routers/analyze.py index 12693c8..ae966dd 100644 --- a/backend/routers/analyze.py +++ b/backend/routers/analyze.py @@ -71,6 +71,14 @@ async def analyze_case(payload: AnalysisRequest) -> dict[str, Any]: if not case: raise HTTPException(status_code=404, detail='Case not found') case_data = {**case.to_detail(), **case_data} + # Карточка хранит координаты в tnp_lat/tnp_lon (gps_lat/lon — алиасы + # to_detail). Без этой подстройки case_id-режим терял координаты ТНП: + # rules_analyze не строил geo-зоны и отдавал fallback «Ближняя N / + # Средняя E» — источник «вверх-вправо» на карте. + if case_data.get('lat') is None: + case_data['lat'] = case_data.get('tnp_lat') or case_data.get('gps_lat') + if case_data.get('lon') is None: + case_data['lon'] = case_data.get('tnp_lon') or case_data.get('gps_lon') search_input = SearchInput( age=case_data.get('age'), diff --git a/scripts/check-zones.sh b/scripts/check-zones.sh new file mode 100644 index 0000000..a2b74c9 --- /dev/null +++ b/scripts/check-zones.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Проверка: какие зоны отдаёт /analyze для кейса с координатами +TOKEN=$(curl -s -m 8 -X POST localhost:8000/api/v1/auth/login \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data 'username=admin&password=pass123' \ + | python3 -c 'import sys,json; print(json.load(sys.stdin)["access_token"])') +curl -s -m 60 -X POST localhost:8000/api/v1/analyze \ + -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \ + -d '{"case_id": "554d23b3-3f8e-41ce-9040-56712f747f9f"}' > /tmp/az.json +python3 /tmp/check_zones.py \ No newline at end of file diff --git a/scripts/check_zones.py b/scripts/check_zones.py new file mode 100644 index 0000000..0609eb4 --- /dev/null +++ b/scripts/check_zones.py @@ -0,0 +1,8 @@ +import json +d = json.load(open('/tmp/az.json')) +z = d.get('primary_zones', []) +print('zones:', len(z)) +for x in z[:5]: + print(' ', x.get('direction'), x.get('distance'), (x.get('name') or '')[:35], '|', (x.get('reason') or '')[:40]) +print('lat/lon в коэффициентах не видно; fallback_used:', d.get('fallback_used')) +print('max_distance_km:', d.get('max_distance_km')) \ No newline at end of file