Spaces:
Paused
Paused
Download scratch/raw_debug.py from 3SCError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scratch/raw_debug.py
- Command line
-
hf download hf://spaces/3SCError404/nexus/scratch/raw_debug.py
-
curl -L -o raw_debug.py https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scratch/raw_debug.py
1.25 kB
| import asyncio | |
| import os | |
| import sys | |
| # Add current directory to path for imports | |
| sys.path.append(os.getcwd()) | |
| from core.database import async_session_factory | |
| from sqlalchemy import text | |
| async def debug_db(): | |
| async with async_session_factory() as db: | |
| # 1. Total counts | |
| t_res = await db.execute(text("SELECT count(*) FROM tickets WHERE deleted_at IS NULL")) | |
| u_res = await db.execute(text("SELECT count(*) FROM users")) | |
| print(f"Total Active Tickets: {t_res.scalar()}") | |
| print(f"Total Users: {u_res.scalar()}") | |
| # 2. Check a few tickets and their creators' roles | |
| query = text(""" | |
| SELECT t.title, t.workspace_id, t.created_by, u.email, u.role | |
| FROM tickets t | |
| LEFT JOIN users u ON t.created_by = u.id | |
| WHERE t.deleted_at IS NULL | |
| LIMIT 10 | |
| """) | |
| res = await db.execute(query) | |
| print("\nSample Tickets & Creator Roles:") | |
| for row in res.all(): | |
| print(f" Title: {row[0]}") | |
| print(f" WS: {row[1]}") | |
| print(f" Creator Email: {row[3]}") | |
| print(f" Creator Role: {row[4]}") | |
| print("-" * 20) | |
| if __name__ == "__main__": | |
| asyncio.run(debug_db()) | |