Bedre sync

This commit is contained in:
2026-04-13 14:22:27 +02:00
parent e86173f7ec
commit cb204baa50
7 changed files with 53 additions and 12 deletions

View File

@@ -53,6 +53,8 @@ class SongAltDanceData(BaseModel):
class PlaylistSongData(BaseModel):
song_local_id: str
song_title: str = ""
song_artist: str = ""
position: int
status: str = "pending"
is_workshop: bool = False
@@ -182,7 +184,15 @@ def push(
playlist_id_map[pl.local_id] = project.id
for ps in pl.songs:
# Prøv først via song_id_map (lokal ID)
song_id = song_id_map.get(ps.song_local_id)
# Fallback: match på titel+artist
if not song_id and ps.song_title:
existing_song = db.query(Song).filter_by(
title=ps.song_title, artist=ps.song_artist
).first()
if existing_song:
song_id = existing_song.id
if not song_id:
continue
proj_song = ProjectSong(