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