fix/spa-reconnect-no-demo-data #1

Merged
Erik merged 2 commits from fix/spa-reconnect-no-demo-data into main 2026-07-09 10:56:18 +00:00
2 changed files with 10 additions and 5 deletions
Showing only changes of commit 3d52e0b79e - Show all commits

4
_db.py
View File

@ -16,6 +16,6 @@ real connection opens only when a query actually executes.
"""
from __future__ import annotations
from app.db.mariadb import run_select_query # noqa: F401 (kernel SELECT-only proxy)
from app.db.mariadb import run_select_query, cached_select # noqa: F401 (kernel read proxies)
__all__ = ["run_select_query"]
__all__ = ["run_select_query", "cached_select"]

View File

@ -46,7 +46,7 @@ from typing import Any, Optional
from fastapi import APIRouter, Query
from .._db import run_select_query
from .._db import run_select_query, cached_select
logger = logging.getLogger(__name__)
@ -128,8 +128,11 @@ def _group_carts(rows: list[dict[str, Any]], colors: dict[str, int]) -> "dict[st
def _fetch_presses(plant: str) -> list[str]:
# Reference data (admin-edited), re-read on every 12s poll — served from the shared
# reference cache so it stops consuming a pool checkout each poll.
try:
rows = run_select_query(
rows = cached_select(
f"tov:presses:{plant}",
"SELECT psPress AS press FROM press_settings.presses WHERE psPlant = :plant "
"ORDER BY CAST(psPress AS UNSIGNED), psPress",
{"plant": plant},
@ -239,8 +242,10 @@ def _fetch_downtime_reasons(plant: str) -> dict[str, int]:
def _fetch_reason_texts() -> dict[int, str]:
# Reference data (admin-edited), full-table read on every poll — served from cache.
try:
rows = run_select_query(
rows = cached_select(
"tov:reason_texts",
"SELECT id, reason_DE AS de FROM settings.downtime_reasons", {}
)
except Exception as e: # noqa: BLE001