diff --git a/music-lab/app/db.py b/music-lab/app/db.py index b60199e..de5cd11 100644 --- a/music-lab/app/db.py +++ b/music-lab/app/db.py @@ -958,7 +958,12 @@ def create_pipeline(track_id: int) -> int: def get_pipeline(pid: int) -> Optional[Dict[str, Any]]: with _conn() as conn: - row = conn.execute("SELECT * FROM video_pipelines WHERE id = ?", (pid,)).fetchone() + row = conn.execute(""" + SELECT vp.*, ml.title AS track_title + FROM video_pipelines vp + LEFT JOIN music_library ml ON ml.id = vp.track_id + WHERE vp.id = ? + """, (pid,)).fetchone() if not row: return None return _parse_pipeline_row(row) @@ -985,15 +990,16 @@ def update_pipeline_state(pid: int, state: str, **fields) -> None: def list_pipelines(active_only: bool = False) -> List[Dict[str, Any]]: + sql = """ + SELECT vp.*, ml.title AS track_title + FROM video_pipelines vp + LEFT JOIN music_library ml ON ml.id = vp.track_id + """ + if active_only: + sql += " WHERE vp.state NOT IN ('published','cancelled','failed','awaiting_manual')" + sql += " ORDER BY vp.created_at DESC" with _conn() as conn: - if active_only: - rows = conn.execute(""" - SELECT * FROM video_pipelines - WHERE state NOT IN ('published','cancelled','failed','awaiting_manual') - ORDER BY created_at DESC - """).fetchall() - else: - rows = conn.execute("SELECT * FROM video_pipelines ORDER BY created_at DESC").fetchall() + rows = conn.execute(sql).fetchall() return [_parse_pipeline_row(r) for r in rows]