Make backend start on PostgreSQL
This commit is contained in:
@@ -27,6 +27,8 @@ CACHE_TTL_HOURS = 24
|
||||
OVERPASS_URL = "https://overpass-api.de/api/interpreter"
|
||||
|
||||
# Direction mappings
|
||||
SEARCH_DISTANCES = [500, 1000, 2000, 5000]
|
||||
|
||||
DIRECTIONS = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
|
||||
DIRECTION_ANGLES = {
|
||||
"N": 0,
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from backend.database import db
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
from backend.database import db
|
||||
except ImportError: # pragma: no cover - compatibility for direct service imports
|
||||
from database import db
|
||||
|
||||
|
||||
def summary() -> dict:
|
||||
@@ -9,3 +14,26 @@ def summary() -> dict:
|
||||
|
||||
def heatmap() -> list[dict]:
|
||||
return db.heatmap()
|
||||
|
||||
|
||||
def get_statistical_recommendation(case_data: dict[str, Any]) -> dict[str, Any]:
|
||||
score = 0
|
||||
age = case_data.get('age') or case_data.get('age_years')
|
||||
elapsed = case_data.get('elapsed_hours')
|
||||
terrain = str(case_data.get('terrain') or case_data.get('terrain_primary') or '').lower()
|
||||
weather = str(case_data.get('weather') or case_data.get('precipitation') or '').lower()
|
||||
|
||||
if age is not None and age < 12:
|
||||
score += 20
|
||||
if elapsed is not None and elapsed >= 12:
|
||||
score += 20
|
||||
if any(token in terrain for token in ('лес', 'болото', 'вода')):
|
||||
score += 15
|
||||
if any(token in weather for token in ('дождь', 'туман', 'снег', 'ночь')):
|
||||
score += 15
|
||||
|
||||
return {
|
||||
'score': score,
|
||||
'priority': 'high' if score >= 40 else 'normal',
|
||||
'recommendation': 'Высокий приоритет на прочёс и дрон' if score >= 40 else 'Стандартный приоритет поиска',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user