Rettet
This commit is contained in:
@@ -72,12 +72,13 @@ class PlaylistData(BaseModel):
|
||||
songs: list[PlaylistSongData] = []
|
||||
|
||||
class PushPayload(BaseModel):
|
||||
songs: list[SongData] = []
|
||||
dances: list[DanceData] = []
|
||||
song_dances: list[SongDanceData] = []
|
||||
song_alts: list[SongAltDanceData] = []
|
||||
playlists: list[PlaylistData] = []
|
||||
deleted_playlists: list[str] = [] # server-IDs (Project.id)
|
||||
songs: list[SongData] = []
|
||||
dances: list[DanceData] = []
|
||||
song_dances: list[SongDanceData] = []
|
||||
song_alts: list[SongAltDanceData] = []
|
||||
playlists: list[PlaylistData] = []
|
||||
deleted_playlists: list[str] = [] # server-IDs (Project.id)
|
||||
songs_with_dances_synced: list[str] = [] # sang-IDs der er fuldt synkroniseret
|
||||
|
||||
|
||||
# ── Hjælpefunktion: find eller opret sang globalt ─────────────────────────────
|
||||
@@ -207,10 +208,10 @@ def push(
|
||||
), {"id": str(uuid.uuid4()), "song_id": song_id,
|
||||
"dance_id": dance_id, "dance_order": sd.dance_order})
|
||||
|
||||
# Sange pushet uden dans-tags — slet også på server
|
||||
sent_local_ids = {sd.song_local_id for sd in payload.song_dances}
|
||||
for local_id, song_id in song_id_map.items():
|
||||
if local_id in sent_local_ids and song_id not in synced_song_ids:
|
||||
# Sange der er fuldt synkroniseret men har ingen dans-tags — slet på server
|
||||
for local_id in payload.songs_with_dances_synced:
|
||||
song_id = song_id_map.get(local_id)
|
||||
if song_id and song_id not in synced_song_ids:
|
||||
db.execute(_sa.text("DELETE FROM song_dances WHERE song_id=:sid"),
|
||||
{"sid": song_id})
|
||||
|
||||
|
||||
@@ -245,14 +245,18 @@ class SyncManager:
|
||||
).fetchall()
|
||||
]
|
||||
|
||||
# Alle sang-IDs der pusher dans-tags fuldt (inkl. dem med 0 tags)
|
||||
all_song_ids = [s["local_id"] for s in songs]
|
||||
|
||||
conn.close()
|
||||
return {
|
||||
"songs": songs,
|
||||
"dances": dances,
|
||||
"song_dances": song_dances,
|
||||
"song_alts": song_alts,
|
||||
"playlists": playlists,
|
||||
"deleted_playlists": deleted,
|
||||
"songs": songs,
|
||||
"dances": dances,
|
||||
"song_dances": song_dances,
|
||||
"song_alts": song_alts,
|
||||
"playlists": playlists,
|
||||
"deleted_playlists": deleted,
|
||||
"songs_with_dances_synced": all_song_ids,
|
||||
}
|
||||
|
||||
# ── Gem server-IDs ────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user