check-current-status.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkCurrentStatus() {
  4. try {
  5. const book = await prisma.book.findUnique({
  6. where: { id: 1 },
  7. include: {
  8. chapters: {
  9. orderBy: [
  10. { level: 'asc' },
  11. { number: 'asc' }
  12. ]
  13. }
  14. }
  15. });
  16. console.log('📖 书籍状态:');
  17. console.log(` ID: ${book.id}`);
  18. console.log(` 标题: ${book.title}`);
  19. console.log(` 状态: ${book.status}`);
  20. console.log(` 进度: ${book.progress}%`);
  21. console.log('');
  22. // 统计各级章节
  23. const level1 = book.chapters.filter(c => c.level === 1);
  24. const level2 = book.chapters.filter(c => c.level === 2);
  25. const level3 = book.chapters.filter(c => c.level === 3);
  26. console.log('📊 大纲统计:');
  27. console.log(` 章: ${level1.length}`);
  28. console.log(` 节: ${level2.length}`);
  29. console.log(` 小节: ${level3.length}`);
  30. console.log('');
  31. // 检查内容生成状态
  32. const contentStatus = {
  33. null: level3.filter(c => c.contentStatus === null).length,
  34. pending: level3.filter(c => c.contentStatus === 'pending').length,
  35. generating: level3.filter(c => c.contentStatus === 'generating').length,
  36. completed: level3.filter(c => c.contentStatus === 'completed').length,
  37. failed: level3.filter(c => c.contentStatus === 'failed').length,
  38. };
  39. console.log('📝 内容生成状态 (小节级别):');
  40. console.log(` 未开始: ${contentStatus.null}`);
  41. console.log(` 待生成: ${contentStatus.pending}`);
  42. console.log(` 生成中: ${contentStatus.generating}`);
  43. console.log(` 已完成: ${contentStatus.completed}`);
  44. console.log(` 失败: ${contentStatus.failed}`);
  45. console.log('');
  46. // 检查是否有正在生成的
  47. if (contentStatus.generating > 0) {
  48. const generating = level3.filter(c => c.contentStatus === 'generating');
  49. console.log('🔄 正在生成的小节:');
  50. generating.forEach(c => {
  51. console.log(` - ${c.title}`);
  52. });
  53. console.log('');
  54. }
  55. // 显示前3个已完成和未完成的小节
  56. const completed = level3.filter(c => c.contentStatus === 'completed').slice(0, 3);
  57. const notCompleted = level3.filter(c => c.contentStatus !== 'completed').slice(0, 3);
  58. if (completed.length > 0) {
  59. console.log('✅ 已完成的小节示例:');
  60. completed.forEach(c => {
  61. console.log(` - ${c.title} (${c.wordCount}字)`);
  62. });
  63. console.log('');
  64. }
  65. if (notCompleted.length > 0) {
  66. console.log('⏳ 待生成的小节示例:');
  67. notCompleted.forEach(c => {
  68. console.log(` - ${c.title} [${c.contentStatus || 'null'}]`);
  69. });
  70. }
  71. } catch (error) {
  72. console.error('错误:', error);
  73. } finally {
  74. await prisma.$disconnect();
  75. }
  76. }
  77. checkCurrentStatus();