CognxSafeTrack
Claude Sonnet 4.6
refactor(worker): Sprint 2 β dead code removal and queue consolidation
37fb9ce Download scripts/db-ops/audit_db.ts from safetrack/edtech: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/safetrack/edtech/resolve/main/scripts/db-ops/audit_db.ts
- Command line
-
hf download hf://spaces/safetrack/edtech/scripts/db-ops/audit_db.ts
-
curl -L -o audit_db.ts https://huggingface.co/spaces/safetrack/edtech/resolve/main/scripts/db-ops/audit_db.ts
1.46 kB
| import 'dotenv/config'; | |
| import path from 'path'; | |
| import dotenv from 'dotenv'; | |
| dotenv.config({ path: path.join(__dirname, '../../../../.env') }); | |
| import { PrismaClient } from '@prisma/client'; | |
| const prisma = new PrismaClient(); | |
| async function audit() { | |
| const orgId = 'default-org-id'; | |
| const org = await prisma.organization.findUnique({ | |
| where: { id: orgId }, | |
| include: { phoneNumbers: true } | |
| }); | |
| if (!org) { | |
| console.log(`β Organization ${orgId} NOT FOUND in DB.`); | |
| const allOrgs = await prisma.organization.findMany({ take: 5 }); | |
| console.log('Available Orgs:', allOrgs.map(o => ({ id: o.id, name: o.name }))); | |
| } else { | |
| console.log(`β Organization Found: ${org.name} (${org.id})`); | |
| console.log('System User Token present:', !!org.systemUserToken); | |
| if (org.systemUserToken) { | |
| console.log('Token starts with enc:', org.systemUserToken.startsWith('enc:')); | |
| } | |
| console.log('Phone Numbers count:', org.phoneNumbers.length); | |
| if (org.phoneNumbers.length > 0) { | |
| console.log('First Phone Number ID:', org.phoneNumbers[0].id); | |
| } | |
| } | |
| const messages = await prisma.message.findMany({ | |
| take: 5, | |
| orderBy: { createdAt: 'desc' } | |
| }); | |
| console.log('Recent Messages:', messages.map(m => ({ id: m.id, direction: m.direction, status: m.status }))); | |
| await prisma.$disconnect(); | |
| } | |
| audit().catch(console.error); | |