From 1a9abffab5ff79a3cba3b4274c23db5255179c78 Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Tue, 26 May 2026 18:02:28 -0400 Subject: [PATCH] Fix End All Sessions to delete session rows and return correct deleted count --- archive_bot/watchparty.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/archive_bot/watchparty.py b/archive_bot/watchparty.py index eecaec8..1f13990 100644 --- a/archive_bot/watchparty.py +++ b/archive_bot/watchparty.py @@ -721,23 +721,10 @@ def end_all_watch_party_sessions() -> dict[str, Any]: except Exception as exc: print(f"Failed to notify worker of stop during session end_all: {exc}", flush=True) - with connect_db() as connection: - connection.execute( - "UPDATE watch_party_sessions SET status = 'stopped', updated_at = ? WHERE id = ?", - (utc_now(), session_id), - ) - connection.execute( - """ - INSERT OR REPLACE INTO watch_party_worker_state( - session_id, worker_status, playback_state, current_title, position_seconds, - duration_seconds, last_error, updated_at - ) - VALUES (?, 'idle', 'idle', '', 0, 0, '', ?) - """, - (session_id, utc_now()), - ) - log_watch_party_event(connection, session_id, "session.status", {"status": "stopped"}) - connection.commit() + with connect_db() as connection: + cursor = connection.execute("DELETE FROM watch_party_sessions") + deleted_count = cursor.rowcount + connection.commit() - return {"ok": True, "endedCount": len(session_ids)} + return {"ok": True, "endedCount": deleted_count}