fix/spa-reconnect-no-demo-data #1
4
_db.py
4
_db.py
@ -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"]
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user