MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / clear_chat_sessions

Function clear_chat_sessions

skills/storage-helper/scripts/db_ops.py:513–531  ·  view source on GitHub ↗

Delete all GUI chat sessions and messages for one user.

(user_id: str)

Source from the content-addressed store, hash-verified

511
512
513def clear_chat_sessions(user_id: str) -> int:
514 """Delete all GUI chat sessions and messages for one user."""
515 normalized_user_id = _normalize_identifier(user_id)
516 if not normalized_user_id:
517 raise ValueError("user_id is required")
518
519 ensure_chat_tables()
520 conn = get_connection()
521 cursor = conn.cursor()
522 count_row = cursor.execute(
523 "SELECT COUNT(*) AS count FROM chat_sessions WHERE user_id = ?",
524 (normalized_user_id,),
525 ).fetchone()
526 deleted = int(count_row["count"] if count_row else 0)
527 cursor.execute("DELETE FROM chat_messages WHERE user_id = ?", (normalized_user_id,))
528 cursor.execute("DELETE FROM chat_sessions WHERE user_id = ?", (normalized_user_id,))
529 conn.commit()
530 conn.close()
531 return deleted
532
533
534# ============== Profile Operations ==============

Callers

nothing calls this directly

Calls 6

_normalize_identifierFunction · 0.85
ensure_chat_tablesFunction · 0.85
cursorMethod · 0.80
get_connectionFunction · 0.70
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected