Files
livedash-node/scripts/test-processing-status.js
Max Kowalski 653d70022b Broken shit
2025-06-26 21:00:19 +02:00

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();