Manglede tabeller
This commit is contained in:
@@ -140,27 +140,43 @@ def push(
|
||||
db.flush()
|
||||
dance_id_map[key] = dance.id
|
||||
|
||||
# ── Community dans-tags ────────────────────────────────────────────────────
|
||||
# ── Sang-dans tags (brugerens egne) ───────────────────────────────────────
|
||||
from app.models import SongDance, SongAltDance
|
||||
for sd in payload.song_dances:
|
||||
song_id = song_id_map.get(sd.song_local_id)
|
||||
if not song_id:
|
||||
continue
|
||||
song = db.query(Song).filter_by(id=song_id).first()
|
||||
level_id = level_map.get(sd.level_name.lower()) if sd.level_name else None
|
||||
key = f"{sd.dance_name.lower()}|{level_id}"
|
||||
dance_id = dance_id_map.get(key)
|
||||
if not dance_id:
|
||||
continue
|
||||
# Indsend som community dans-tag
|
||||
existing = db.query(CommunityDance).filter_by(
|
||||
song_title=song.title, song_artist=song.artist, dance_id=dance_id
|
||||
existing = db.query(SongDance).filter_by(
|
||||
song_id=song_id, dance_id=dance_id
|
||||
).first()
|
||||
if not existing:
|
||||
cd = CommunityDance(
|
||||
song_title=song.title, song_artist=song.artist,
|
||||
dance_id=dance_id, submitted_by=me.id,
|
||||
)
|
||||
db.add(cd)
|
||||
db.add(SongDance(
|
||||
song_id=song_id, dance_id=dance_id,
|
||||
dance_order=sd.dance_order,
|
||||
))
|
||||
|
||||
for sa in payload.song_alts:
|
||||
song_id = song_id_map.get(sa.song_local_id)
|
||||
if not song_id:
|
||||
continue
|
||||
level_id = level_map.get(sa.level_name.lower()) if sa.level_name else None
|
||||
key = f"{sa.dance_name.lower()}|{level_id}"
|
||||
dance_id = dance_id_map.get(key)
|
||||
if not dance_id:
|
||||
continue
|
||||
existing = db.query(SongAltDance).filter_by(
|
||||
song_id=song_id, dance_id=dance_id
|
||||
).first()
|
||||
if not existing:
|
||||
db.add(SongAltDance(
|
||||
song_id=song_id, dance_id=dance_id,
|
||||
note=sa.note,
|
||||
))
|
||||
|
||||
# ── Playlister ────────────────────────────────────────────────────────────
|
||||
playlist_id_map = {}
|
||||
@@ -301,18 +317,20 @@ def pull(
|
||||
"songs": sorted(songs_out, key=lambda x: x["position"]),
|
||||
})
|
||||
|
||||
# Brugerens egne dans-tags (via community dances submitted_by me)
|
||||
# Brugerens egne dans-tags
|
||||
from app.models import SongDance, SongAltDance
|
||||
song_tags = []
|
||||
for cd in db.query(CommunityDance).filter_by(submitted_by=me.id).all():
|
||||
dance = db.query(Dance).filter_by(id=cd.dance_id).first()
|
||||
for sd in db.query(SongDance).join(Song).filter(Song.owner_id == me.id).all():
|
||||
dance = db.query(Dance).filter_by(id=sd.dance_id).first()
|
||||
if not dance:
|
||||
continue
|
||||
level = db.query(DanceLevel).filter_by(id=dance.level_id).first() if dance.level_id else None
|
||||
song_tags.append({
|
||||
"song_title": cd.song_title,
|
||||
"song_artist": cd.song_artist,
|
||||
"song_title": sd.song.title,
|
||||
"song_artist": sd.song.artist,
|
||||
"dance_name": dance.name,
|
||||
"level_name": level.name if level else "",
|
||||
"dance_order": sd.dance_order,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user