Fix End All Sessions to delete session rows and return correct deleted count

This commit is contained in:
MiTHRAL 2026-05-26 18:02:28 -04:00
parent d9c9d8ee8e
commit 1a9abffab5

View file

@ -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}