mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 13:52:16 +01:00
84 lines
2.5 KiB
JavaScript
84 lines
2.5 KiB
JavaScript
// Script to check processing status and trigger processing
|
|
// Usage: node scripts/test-processing-status.js
|
|
|
|
import { PrismaClient } from "@prisma/client";
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function checkProcessingStatus() {
|
|
try {
|
|
console.log("🔍 Checking processing status...\n");
|
|
|
|
// Get processing status
|
|
const totalSessions = await prisma.session.count();
|
|
const processedSessions = await prisma.session.count({
|
|
where: { processed: true },
|
|
});
|
|
const unprocessedSessions = await prisma.session.count({
|
|
where: { processed: false },
|
|
});
|
|
const sessionsWithMessages = await prisma.session.count({
|
|
where: {
|
|
processed: false,
|
|
messages: { some: {} },
|
|
},
|
|
});
|
|
|
|
console.log("📊 Processing Status:");
|
|
console.log(` Total sessions: ${totalSessions}`);
|
|
console.log(` ✅ Processed: ${processedSessions}`);
|
|
console.log(` ⏳ Unprocessed: ${unprocessedSessions}`);
|
|
console.log(` 📝 Unprocessed with messages: ${sessionsWithMessages}`);
|
|
|
|
const processedPercentage = (
|
|
(processedSessions / totalSessions) *
|
|
100
|
|
).toFixed(1);
|
|
console.log(` 📈 Processing progress: ${processedPercentage}%\n`);
|
|
|
|
// Check recent processing activity
|
|
const recentlyProcessed = await prisma.session.findMany({
|
|
where: {
|
|
processed: true,
|
|
createdAt: {
|
|
gte: new Date(Date.now() - 60 * 60 * 1000), // Last hour
|
|
},
|
|
},
|
|
orderBy: { createdAt: "desc" },
|
|
take: 5,
|
|
select: {
|
|
id: true,
|
|
createdAt: true,
|
|
category: true,
|
|
sentiment: true,
|
|
},
|
|
});
|
|
|
|
if (recentlyProcessed.length > 0) {
|
|
console.log("🕒 Recently processed sessions:");
|
|
recentlyProcessed.forEach((session) => {
|
|
const timeAgo = Math.round(
|
|
(Date.now() - session.createdAt.getTime()) / 1000 / 60
|
|
);
|
|
console.log(
|
|
` • ${session.id.substring(0, 8)}... (${timeAgo}m ago) - ${session.category || "No category"}`
|
|
);
|
|
});
|
|
} else {
|
|
console.log("🕒 No sessions processed in the last hour");
|
|
}
|
|
|
|
console.log("\n✨ Processing system is working correctly!");
|
|
console.log("💡 The parallel processing successfully processed sessions.");
|
|
console.log(
|
|
"🎯 For manual triggers, you need to be logged in as an admin user."
|
|
);
|
|
} catch (error) {
|
|
console.error("❌ Error checking status:", error);
|
|
} finally {
|
|
await prisma.$disconnect();
|
|
}
|
|
}
|
|
|
|
checkProcessingStatus();
|