| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- const { prisma } = require('../src/models');
- async function main() {
- const total = await prisma.aiCallLog.count();
- console.log('=== AiCallLog 总数: ' + total + ' ===\n');
-
- const byType = await prisma.aiCallLog.groupBy({
- by: ['callType', 'provider'],
- _count: { id: true },
- });
- byType.sort((a: any, b: any) => b._count.id - a._count.id);
-
- for (const t of byType) {
- console.log(` ${t.callType.padEnd(30)} | ${(t.provider||'-').padEnd(15)} | ${t._count.id} 次`);
- }
-
- const success = await prisma.aiCallLog.count({ where: { success: true }});
- const failed = await prisma.aiCallLog.count({ where: { success: false }});
- console.log(`\n 成功: ${success} | 失败: ${failed}`);
-
- // TTS-only count
- const ttsTotal = await prisma.aiCallLog.count({ where: { callType: { startsWith: 'tts' } } });
- const llmTotal = await prisma.aiCallLog.count({ where: { callType: { startsWith: 'llm' } } });
- console.log(` TTS: ${ttsTotal} | LLM: ${llmTotal}`);
-
- // Show recent entries
- const recent = await prisma.aiCallLog.findMany({
- orderBy: { createdAt: 'desc' },
- take: 10,
- select: { callType: true, provider: true, success: true, duration: true, errorMsg: true }
- });
- console.log('\n=== 最近10条 ===');
- for (const r of recent) {
- const s = r.success ? '✅' : '❌';
- const e = r.errorMsg ? ` (${r.errorMsg.substring(0,50)})` : '';
- console.log(` ${s} ${r.callType.padEnd(25)} ${(r.provider||'-').padEnd(12)} ${r.duration}ms${e}`);
- }
-
- await prisma.$disconnect();
- }
- main().catch(e => { console.error(e); process.exit(1); });
|