Spaces:
3SCError404
/
Paused

nexus / scratch /debug_tickets.py
dushyantsingh0
backend stabilization
630aa02
Raw History Blame Contribute Delete
804 Bytes
import asyncio
from core.database import async_session_factory
from models.user import User
from models.ticket import Ticket
from sqlalchemy import select
async def run():
async with async_session_factory() as db:
# Get users
res = await db.execute(select(User))
users = res.scalars().all()
print(f"Total Users: {len(users)}")
for u in users:
print(f" {u.email} | Role: {u._legacy_role} | WS: {u._legacy_workspace_id}")
# Get tickets
res = await db.execute(select(Ticket))
tickets = res.scalars().all()
print(f"Total Tickets: {len(tickets)}")
for t in tickets:
print(f" {t.title} | WS: {t.workspace_id} | CreatedBy: {t.created_by}")
if __name__ == "__main__":
asyncio.run(run())