40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
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:
|
|
return db.stats()
|
|
|
|
|
|
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 'Стандартный приоритет поиска',
|
|
}
|