DB-flush - Server

This commit is contained in:
2026-04-19 01:02:56 +02:00
parent e4ab9caab6
commit 24bb71cdd7

View File

@@ -156,7 +156,6 @@ def push(
# ── Sang-dans tags (brugerens egne) ───────────────────────────────────────
from app.models import SongDance, SongAltDance
# Slet eksisterende song_dances for disse sange og genindsæt
# — sikrer at rækkefølge og ændringer altid er korrekte
affected_song_ids = set(
song_id_map[sd.song_local_id]
for sd in payload.song_dances
@@ -166,7 +165,9 @@ def push(
db.query(SongDance).filter(
SongDance.song_id.in_(affected_song_ids)
).delete(synchronize_session=False)
db.flush()
with db.no_autoflush:
for sd in payload.song_dances:
song_id = song_id_map.get(sd.song_local_id)
if not song_id:
@@ -190,7 +191,9 @@ def push(
db.query(SongAltDance).filter(
SongAltDance.song_id.in_(affected_alt_ids)
).delete(synchronize_session=False)
db.flush()
with db.no_autoflush:
for sa in payload.song_alts:
song_id = song_id_map.get(sa.song_local_id)
if not song_id: