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