check-status.ts 1.3 KB

123456789101112131415161718192021222324252627
  1. const { prisma } = require('../src/models');
  2. (async () => {
  3. // All books status
  4. const books = await prisma.book.findMany({
  5. where: { id: { gte: 56 } },
  6. orderBy: { id: 'desc' }, take: 5,
  7. select: { id: true, title: true, genStage: true, progress: true }
  8. });
  9. console.log('=== Recent Books ===');
  10. for (const b of books) console.log(` #${b.id} "${(b.title||'').substring(0,20)}" stage=${b.genStage} progress=${b.progress}`);
  11. // AiCallLog
  12. const total = await prisma.aiCallLog.count();
  13. const byType = await prisma.aiCallLog.groupBy({ by: ['callType'], _count: { id: true } });
  14. byType.sort((a,b) => b._count.id - a._count.id);
  15. console.log('\n=== AiCallLog (' + total + ' total) ===');
  16. for (const t of byType) console.log(` ${t.callType.padEnd(25)} ${t._count.id} 次`);
  17. // Bug check: any chapters stuck?
  18. const stuckContent = await prisma.bookChapter.count({ where: { genStage: 'content_generating', content: null } });
  19. const stuckAudio = await prisma.bookChapter.count({ where: { genStage: 'audio_generating', audioUrl: '' } });
  20. console.log('\n=== Stuck chapters ===');
  21. console.log(` content_generating (no content): ${stuckContent}`);
  22. console.log(` audio_generating (no audioUrl): ${stuckAudio}`);
  23. await prisma.$disconnect();
  24. })();