| 12345678910111213141516171819202122 |
- const { prisma } = require('../src/models');
- async function check() {
- const count = await prisma.aiCallLog.count();
- console.log('AiCallLog 总记录:', count);
- if (count > 0) {
- const latest = await prisma.aiCallLog.findMany({ take: 15, orderBy: { id: 'desc' } });
- console.log('\n最近 15 条:');
- latest.forEach(l =>
- console.log(` ${l.callType.padEnd(14)} ${l.provider.padEnd(18)} ${l.success ? 'OK' : 'FAIL'} ${String(l.duration).padStart(6)}ms ${String(l.textLen || '').padStart(6)}字 ${l.errorMsg || ''}`)
- );
- const stats: any = await prisma.$queryRaw`SELECT callType, COUNT(*) as cnt, SUM(duration) as totalMs FROM AiCallLog GROUP BY callType ORDER BY cnt DESC`;
- console.log('\n按类型统计:');
- stats.forEach((s: any) => console.log(` ${s.callType}: ${s.cnt}次, ${Math.round(s.totalMs / 1000)}s`));
- } else {
- console.log('(日志为空,服务可能未重启加载新代码)');
- }
- await prisma.$disconnect();
- }
- check().catch(e => { console.error(e); process.exit(1); });
|