mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
fix(core): clean predictor debt
This commit is contained in:
1 parent
e952cea417
commit
e6add1b727
10 files changed
+268
-58
No files matched your search
+23
-17
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user