auto-sync: 2026-05-04 11:40:01

This commit is contained in:
Stream
2026-05-04 11:40:01 +03:00
parent 8ebc01ea2b
commit ab569eae10
4 changed files with 105 additions and 0 deletions

View File

@@ -497,6 +497,33 @@ async def post_route(req: RouteRequest):
except Exception as e:
raise HTTPException(503, f"OSRM недоступен: {e}")
# OSRM возвращает TooBig когда маршрут слишком длинный для N альтернатив
if data.get("code") == "TooBig":
# Пробуем с меньшим числом альтернатив
url_retry3 = (
f"{OSRM_URL}/route/v1/driving/{coords_str}"
f"?alternatives=3&overview=full&geometries=geojson&annotations=false"
)
try:
async with httpx.AsyncClient(timeout=30) as client:
resp = await client.get(url_retry3)
data = resp.json()
except Exception as e:
raise HTTPException(503, f"OSRM недоступен: {e}")
if data.get("code") == "TooBig":
# Всё ещё TooBig — пробуем совсем без альтернатив
url_retry1 = (
f"{OSRM_URL}/route/v1/driving/{coords_str}"
f"?overview=full&geometries=geojson&alternatives=false"
)
try:
async with httpx.AsyncClient(timeout=30) as client:
resp = await client.get(url_retry1)
data = resp.json()
except Exception as e:
raise HTTPException(503, f"OSRM недоступен: {e}")
if data.get("code") != "Ok" or not data.get("routes"):
raise HTTPException(404, "Маршрут не найден")

View File

@@ -7,6 +7,7 @@ function formatDuration(seconds) {
const hours = Math.floor((totalMin % 1440) / 60);
const mins = totalMin % 60;
if (days > 0) {
if (hours === 0 && mins === 0) return `${days} дн`;
if (mins === 0) return `${days} дн ${hours} ч`;
return `${days} дн ${hours} ч ${mins} мин`;
}