Bedre tag sync

This commit is contained in:
2026-04-13 15:33:01 +02:00
parent cb204baa50
commit b066b6d92c
5 changed files with 90 additions and 12 deletions

View File

@@ -224,7 +224,6 @@ def pull(
"""Hent server-data til lokal app."""
# Dans-niveauer
levels = [
{"id": l.id, "name": l.name, "sort_order": l.sort_order}
for l in db.query(DanceLevel).order_by(DanceLevel.sort_order).all()
]
@@ -278,7 +277,10 @@ def pull(
# Egne playlister
my_playlists = []
for p in db.query(Project).filter_by(owner_id=me.id).all():
all_projects = db.query(Project).filter_by(owner_id=me.id).all()
import logging
logging.getLogger(__name__).info(f"Pull: fandt {len(all_projects)} projekter for {me.id}")
for p in all_projects:
songs_out = []
for ps in p.project_songs:
song = db.query(Song).filter_by(id=ps.song_id).first()
@@ -299,10 +301,25 @@ def pull(
"songs": sorted(songs_out, key=lambda x: x["position"]),
})
# Brugerens egne dans-tags (via community dances submitted_by me)
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()
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,
"dance_name": dance.name,
"level_name": level.name if level else "",
})
return {
"levels": levels,
"dances": dances,
"community": community,
"shared": shared,
"my_playlists": my_playlists,
"song_tags": song_tags,
}