54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
|
|
/**
|
|||
|
|
* 查询最新书籍解析任务(course_generation_tasks)
|
|||
|
|
* 用于诊断超时、失败:npx ts-node scripts/check-latest-book-task.ts
|
|||
|
|
* 需在 backend 目录执行,或设置 DATABASE_URL
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
import 'dotenv/config';
|
|||
|
|
import { PrismaClient } from '@prisma/client';
|
|||
|
|
|
|||
|
|
const prisma = new PrismaClient();
|
|||
|
|
|
|||
|
|
async function main() {
|
|||
|
|
const rows = await prisma.courseGenerationTask.findMany({
|
|||
|
|
orderBy: { createdAt: 'desc' },
|
|||
|
|
take: 5,
|
|||
|
|
select: {
|
|||
|
|
id: true,
|
|||
|
|
courseId: true,
|
|||
|
|
userId: true,
|
|||
|
|
status: true,
|
|||
|
|
progress: true,
|
|||
|
|
errorMessage: true,
|
|||
|
|
currentStep: true,
|
|||
|
|
sourceText: true,
|
|||
|
|
createdAt: true,
|
|||
|
|
updatedAt: true,
|
|||
|
|
course: { select: { title: true, totalNodes: true } },
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.log('\n========== 最新 5 条书籍解析任务 ==========\n');
|
|||
|
|
for (let i = 0; i < rows.length; i++) {
|
|||
|
|
const t = rows[i];
|
|||
|
|
const len = typeof t.sourceText === 'string' ? t.sourceText.length : 0;
|
|||
|
|
console.log(`--- 任务 ${i + 1} ---`);
|
|||
|
|
console.log(' id: ', t.id);
|
|||
|
|
console.log(' courseId: ', t.courseId);
|
|||
|
|
console.log(' course.title:', (t.course as any)?.title ?? '-');
|
|||
|
|
console.log(' status: ', t.status);
|
|||
|
|
console.log(' progress: ', t.progress);
|
|||
|
|
console.log(' currentStep:', t.currentStep ?? '-');
|
|||
|
|
console.log(' errorMessage:', t.errorMessage ?? '-');
|
|||
|
|
console.log(' sourceText 长度:', len);
|
|||
|
|
console.log(' createdAt: ', t.createdAt);
|
|||
|
|
console.log(' updatedAt: ', t.updatedAt);
|
|||
|
|
console.log('');
|
|||
|
|
}
|
|||
|
|
console.log('==========================================\n');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
main()
|
|||
|
|
.catch((e) => { console.error(e); process.exit(1); })
|
|||
|
|
.finally(() => prisma.$disconnect());
|