fix(core): clean predictor debt

This commit is contained in:
dasemu committed 2026-03-13 10:51:29 +01:00
1 parent e952cea417
commit e6add1b727
10 files changed
+268 -58

No files matched your search

+23 -17
View File
@@ -23,6 +23,8 @@ from pathlib import Path
from typing import Any
from zoneinfo import ZoneInfo
import yaml
# Ensure the project root is importable when the bot is launched as a script
# (e.g. ``python bot/telegram_bot.py`` from start.sh or systemd).
_BOT_DIR = Path(__file__).resolve().parent
@@ -51,25 +53,29 @@ logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)
# ---------------------------------------------------------------------------
# Station metadata (mirrors config/stations.yaml without adding a runtime
# dependency on pyyaml inside the bot module itself).
# Station metadata
# ---------------------------------------------------------------------------
STATIONS = {
"pajares": {
"name": "Valgrande-Pajares",
"max_km": 22.0,
},
"sanisidro": {
"name": "San Isidro",
"max_km": 31.0,
},
"fuentes": {
"name": "Fuentes de Invierno",
"max_km": 8.6,
},
}
STATION_ORDER = ("pajares", "sanisidro", "fuentes")
_STATIONS_YAML = _PROJECT_ROOT / "config" / "stations.yaml"
def _load_station_metadata() -> dict[str, dict[str, Any]]:
"""Load bot-visible station metadata from the shared YAML config."""
with _STATIONS_YAML.open("r", encoding="utf-8") as fh:
raw = yaml.safe_load(fh) or {}
stations = raw.get("stations") or {}
return {
station_id: {
"name": station_cfg["name"],
"max_km": float(station_cfg["max_km_skiable"]),
}
for station_id, station_cfg in stations.items()
}
STATIONS = _load_station_metadata()
STATION_ORDER = tuple(STATIONS.keys())
DISPLAY_TIMEZONE = ZoneInfo("Europe/Madrid")
SAME_DAY_PREDICTION_CUTOFF_HOUR = 10