check-chapter-audio-update.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkChapterAudio() {
  4. console.log('\n📊 检查BookChapter的audioUrl更新情况:\n');
  5. const bookId = 5;
  6. // 检查前5个小节
  7. const subsections = await prisma.bookChapter.findMany({
  8. where: {
  9. bookId,
  10. level: 3
  11. },
  12. select: {
  13. id: true,
  14. title: true,
  15. audioUrl: true,
  16. audioDuration: true,
  17. },
  18. orderBy: { id: 'desc' },
  19. take: 5
  20. });
  21. console.log('最近5个小节:\n');
  22. subsections.forEach((sub, index) => {
  23. console.log(`${index + 1}. ${sub.title}`);
  24. console.log(` audioUrl: ${sub.audioUrl || '无'}`);
  25. console.log(` audioDuration: ${sub.audioDuration || 0}秒\n`);
  26. });
  27. // 统计
  28. const withAudio = await prisma.bookChapter.count({
  29. where: {
  30. bookId,
  31. level: 3,
  32. audioUrl: { not: '' }
  33. }
  34. });
  35. const totalSubsections = await prisma.bookChapter.count({
  36. where: {
  37. bookId,
  38. level: 3
  39. }
  40. });
  41. console.log(`\n📈 统计:`);
  42. console.log(` 总小节数: ${totalSubsections}`);
  43. console.log(` 有audioUrl的小节: ${withAudio}`);
  44. console.log(` 比例: ${(withAudio / totalSubsections * 100).toFixed(1)}%\n`);
  45. await prisma.$disconnect();
  46. }
  47. checkChapterAudio().catch(console.error);