Fix End All Sessions to delete session rows and return correct deleted count
This commit is contained in:
parent
d9c9d8ee8e
commit
1a9abffab5
1 changed files with 5 additions and 18 deletions
|
|
@ -721,23 +721,10 @@ def end_all_watch_party_sessions() -> dict[str, Any]:
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print(f"Failed to notify worker of stop during session end_all: {exc}", flush=True)
|
print(f"Failed to notify worker of stop during session end_all: {exc}", flush=True)
|
||||||
|
|
||||||
with connect_db() as connection:
|
with connect_db() as connection:
|
||||||
connection.execute(
|
cursor = connection.execute("DELETE FROM watch_party_sessions")
|
||||||
"UPDATE watch_party_sessions SET status = 'stopped', updated_at = ? WHERE id = ?",
|
deleted_count = cursor.rowcount
|
||||||
(utc_now(), session_id),
|
connection.commit()
|
||||||
)
|
|
||||||
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()
|
|
||||||
|
|
||||||
return {"ok": True, "endedCount": len(session_ids)}
|
return {"ok": True, "endedCount": deleted_count}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue