/** * 快速检查 24h LLM/TTS 统计 */ const { prisma } = require('../src/models'); async function main() { const last24h = new Date(Date.now() - 24 * 60 * 60 * 1000); // LLM calls const llmCalls = await prisma.aiCallLog.groupBy({ by: ['callType', 'provider'], where: { callType: { startsWith: 'llm' }, createdAt: { gte: last24h } }, _count: { id: true }, }); llmCalls.sort((a: any, b: any) => b._count.id - a._count.id); console.log('=== 24h LLM 请求 ==='); let total = 0; for (const c of llmCalls) { console.log(` ${c.callType.padEnd(25)} | ${(c.provider||'-').padEnd(20)} | ${c._count.id} 次`); total += c._count.id; } console.log(` LLM 总计: ${total} 次`); // TTS calls const ttsCalls = await prisma.aiCallLog.groupBy({ by: ['callType', 'provider'], where: { callType: { startsWith: 'tts' }, createdAt: { gte: last24h } }, _count: { id: true }, }); ttsCalls.sort((a: any, b: any) => b._count.id - a._count.id); console.log('\n=== 24h TTS 请求 ==='); let ttsTotal = 0; for (const c of ttsCalls) { console.log(` ${c.callType.padEnd(25)} | ${(c.provider||'-').padEnd(20)} | ${c._count.id} 次`); ttsTotal += c._count.id; } console.log(` TTS 总计: ${ttsTotal} 次`); const all24h = await prisma.aiCallLog.count({ where: { createdAt: { gte: last24h } } }); console.log(`\n 24h 全部请求: ${all24h} 次 (LLM ${total} + TTS ${ttsTotal})`); await prisma.$disconnect(); } main().catch(e => { console.error(e); process.exit(1); });