check-calltypes.ts 850 B

123456789101112131415161718192021
  1. const { prisma } = require('../src/models');
  2. async function main() {
  3. const types = await prisma.aiCallLog.groupBy({
  4. by: ['callType'],
  5. _count: { id: true },
  6. });
  7. types.sort((a: any, b: any) => b._count.id - a._count.id);
  8. console.log('=== AiCallLog 所有 callType ===');
  9. for (const t of types) {
  10. console.log(` ${t.callType.padEnd(30)} | ${t._count.id} 次`);
  11. }
  12. // Also check earliest/latest
  13. const first = await prisma.aiCallLog.findFirst({ orderBy: { createdAt: 'asc' }, select: { createdAt: true } });
  14. const last = await prisma.aiCallLog.findFirst({ orderBy: { createdAt: 'desc' }, select: { createdAt: true } });
  15. console.log(`\n 最早记录: ${first?.createdAt}`);
  16. console.log(` 最新记录: ${last?.createdAt}`);
  17. await prisma.$disconnect();
  18. }
  19. main().catch(e => { console.error(e); process.exit(1); });