NY db struktur
This commit is contained in:
@@ -406,9 +406,13 @@ class PlaylistPanel(QWidget):
|
||||
return False
|
||||
|
||||
# Hent sange med status, workshop og dans-override
|
||||
# JOIN songs — sangen er altid i songs tabellen (oprettet ved pull med file_missing=1)
|
||||
# file_missing betyder bare at filen ikke er på denne maskine
|
||||
songs_raw = conn.execute("""
|
||||
SELECT s.*, ps.position, ps.status,
|
||||
ps.is_workshop, ps.dance_override
|
||||
SELECT s.id, s.title, s.artist, s.album,
|
||||
s.bpm, s.duration_sec, s.file_format,
|
||||
s.local_path, s.file_missing,
|
||||
ps.position, ps.status, ps.is_workshop, ps.dance_override
|
||||
FROM playlist_songs ps
|
||||
JOIN songs s ON s.id = ps.song_id
|
||||
WHERE ps.playlist_id=? ORDER BY ps.position
|
||||
@@ -426,10 +430,10 @@ class PlaylistPanel(QWidget):
|
||||
override = row["dance_override"] or ""
|
||||
active_dance = override if override else (dance_names[0] if dance_names else "")
|
||||
|
||||
local_path = row["local_path"]
|
||||
local_path = row["local_path"] or ""
|
||||
file_missing = bool(row["file_missing"])
|
||||
|
||||
# Forsøg at finde sangen lokalt hvis den mangler
|
||||
# Forsøg at finde filen lokalt hvis den mangler på denne maskine
|
||||
if file_missing or not local_path:
|
||||
match = conn.execute("""
|
||||
SELECT local_path FROM songs
|
||||
@@ -444,11 +448,11 @@ class PlaylistPanel(QWidget):
|
||||
"id": row["id"],
|
||||
"title": row["title"],
|
||||
"artist": row["artist"],
|
||||
"album": row["album"],
|
||||
"bpm": row["bpm"],
|
||||
"duration_sec": row["duration_sec"],
|
||||
"album": row["album"] or "",
|
||||
"bpm": row["bpm"] or 0,
|
||||
"duration_sec": row["duration_sec"] or 0,
|
||||
"local_path": local_path,
|
||||
"file_format": row["file_format"],
|
||||
"file_format": row["file_format"] or "",
|
||||
"file_missing": file_missing,
|
||||
"dances": dance_names,
|
||||
"active_dance": active_dance,
|
||||
@@ -605,9 +609,12 @@ class PlaylistPanel(QWidget):
|
||||
else:
|
||||
self._can_edit_server = False
|
||||
with get_db() as conn:
|
||||
# JOIN songs — sangen er altid i songs tabellen (oprettet ved pull med file_missing=1)
|
||||
songs_raw = conn.execute("""
|
||||
SELECT s.*, ps.position, ps.status,
|
||||
ps.is_workshop, ps.dance_override
|
||||
SELECT s.id, s.title, s.artist, s.album,
|
||||
s.bpm, s.duration_sec, s.file_format,
|
||||
s.local_path, s.file_missing,
|
||||
ps.position, ps.status, ps.is_workshop, ps.dance_override
|
||||
FROM playlist_songs ps
|
||||
JOIN songs s ON s.id = ps.song_id
|
||||
WHERE ps.playlist_id=? ORDER BY ps.position
|
||||
@@ -618,17 +625,17 @@ class PlaylistPanel(QWidget):
|
||||
for row in songs_raw:
|
||||
dances = conn.execute("""
|
||||
SELECT d.name FROM song_dances sd
|
||||
JOIN dances d ON d.id = sd.dance_id
|
||||
JOIN dances d ON d.id = sad.dance_id
|
||||
WHERE sd.song_id=? ORDER BY sd.dance_order
|
||||
""", (row["id"],)).fetchall()
|
||||
dance_names = [d["name"] for d in dances]
|
||||
override = row["dance_override"] or ""
|
||||
active_dance = override if override else (dance_names[0] if dance_names else "")
|
||||
|
||||
local_path = row["local_path"]
|
||||
local_path = row["local_path"] or ""
|
||||
file_missing = bool(row["file_missing"])
|
||||
|
||||
# Forsøg at finde sangen lokalt hvis den mangler
|
||||
# Forsøg at finde filen lokalt hvis den mangler på denne maskine
|
||||
if file_missing or not local_path:
|
||||
match = conn.execute("""
|
||||
SELECT local_path FROM songs
|
||||
@@ -644,11 +651,11 @@ class PlaylistPanel(QWidget):
|
||||
"id": row["id"],
|
||||
"title": row["title"],
|
||||
"artist": row["artist"],
|
||||
"album": row["album"],
|
||||
"bpm": row["bpm"],
|
||||
"duration_sec": row["duration_sec"],
|
||||
"album": row["album"] or "",
|
||||
"bpm": row["bpm"] or 0,
|
||||
"duration_sec": row["duration_sec"] or 0,
|
||||
"local_path": local_path,
|
||||
"file_format": row["file_format"],
|
||||
"file_format": row["file_format"] or "",
|
||||
"file_missing": file_missing,
|
||||
"dances": dance_names,
|
||||
"active_dance": active_dance,
|
||||
@@ -1251,4 +1258,4 @@ class PlaylistPanel(QWidget):
|
||||
def _on_double_click(self, item: QListWidgetItem):
|
||||
idx = item.data(Qt.ItemDataRole.UserRole)
|
||||
if idx is not None:
|
||||
self.song_selected.emit(idx)
|
||||
self.song_selected.emit(idx)
|
||||
Reference in New Issue
Block a user