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

+10 -6
View File
@@ -30,10 +30,7 @@ logger = logging.getLogger(__name__)
_PROJECT_ROOT = Path(__file__).resolve().parents[1]
DEFAULT_DB_PATH = Path(
os.environ.get(
"SKIPREDICTOR_DB_PATH",
_PROJECT_ROOT / "data" / "processed" / "skipredictor.db",
)
_PROJECT_ROOT / "data" / "processed" / "skipredictor.db"
)
LATEST_WEATHER_TABLE = "latest_weather_forecast"
@@ -73,8 +70,8 @@ _WEATHER_COLUMNS: list[str] = [
class SQLiteStore:
"""Convenience wrapper around the project SQLite database."""
def __init__(self, db_path: Path | str = DEFAULT_DB_PATH) -> None:
self.db_path = Path(db_path)
def __init__(self, db_path: Path | str | None = None) -> None:
self.db_path = self._resolve_db_path(db_path)
self.db_path.parent.mkdir(parents=True, exist_ok=True)
self._ensure_schema()
@@ -838,6 +835,13 @@ class SQLiteStore:
"""
)
@staticmethod
def _resolve_db_path(db_path: Path | str | None) -> Path:
"""Resolve the effective database path, honoring the environment at runtime."""
if db_path is not None:
return Path(db_path)
return Path(os.environ.get("SKIPREDICTOR_DB_PATH", DEFAULT_DB_PATH))
def _load_prediction_payload(
self,
conn: sqlite3.Connection,