Perf: 9 Performance-Fixes — SW by-v1072
Backend: - DB: 3 neue Indizes (forum_posts thread+user, routes user) — Forum/Routen-Queries - Caching: cache.py (TTL-Cache ohne neue Dependency) für 5 statische Listen (training_exercises, pflege_tipps, wiki_stats, wiki_gruppen, help_articles) - diary.py + breeder_photos.py: Bildverarbeitung (ffmpeg/PIL/EXIF) per run_in_executor → blockiert Event-Loop nicht mehr - scheduler.py: 11 kollidierende Jobs auf 5-Min-Intervalle gestaggert, coalesce=True - social.py: ORDER BY RANDOM() ohne LIMIT in 2 Stellen gefixt - alerts.py: Haversine-Loop bekommt SQL-Bounding-Box-Vorfilter Frontend: - sw.js: Tile-Cache mit LRU-Eviction (max 500 Einträge) - admin.js: Event-Listener-Leak — Tab-Klicks per Delegation statt N Listener - api.js: compressImage() Helper — Client-seitiges Resize auf max 2000px (HEIC/Videos/<500KB unverändert), integriert in 8 Upload-Stellen (diary, dog-profile×2, walks, poison, lost, health×2) Bump APP_VER 1071 → 1072 (sw.js, app.js, main.py, index.html)
This commit is contained in:
parent
3abf974d29
commit
c03884cb81
23 changed files with 461 additions and 120 deletions
|
|
@ -9,6 +9,20 @@ from database import db
|
|||
from auth import get_current_user, has_pro_access
|
||||
from routes.push import send_push_to_user
|
||||
from media_utils import safe_media_path, preview_url_from
|
||||
from cache import ttl_cache
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Pflege-Tipps sind statische Stamm-Daten → 1h TTL-Cache
|
||||
# (Filterung pro Hund passiert weiter unten in-memory, NICHT gecached)
|
||||
# ------------------------------------------------------------------
|
||||
@ttl_cache(ttl=3600)
|
||||
def _load_all_pflege_tipps() -> list[dict]:
|
||||
with db() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT * FROM pflege_tipps ORDER BY kategorie, titel"
|
||||
).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
router = APIRouter()
|
||||
MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media")
|
||||
|
|
@ -1095,10 +1109,8 @@ async def get_pflege_tipps(dog_id: int, user=Depends(get_current_user)):
|
|||
elif any(w in beschr for w in ["schneid", "geschoren", "schere", "clipper"]):
|
||||
fell_pflege_art_filter = "schneiden"
|
||||
|
||||
with db() as conn:
|
||||
alle_tipps = conn.execute(
|
||||
"SELECT * FROM pflege_tipps ORDER BY kategorie, titel"
|
||||
).fetchall()
|
||||
# Statische Tipps aus Cache (1h TTL) – Filterung passiert in-memory
|
||||
alle_tipps = _load_all_pflege_tipps()
|
||||
|
||||
# Relevante Tipps: kein Fell-Filter oder passend
|
||||
from datetime import date
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue