Bedre tag sync
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user