import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); async function fixAnomalies() { console.log("🛠️ Démarrage de la correction des anomalies QA..."); // 1. Fix Pitch Deck Badges on Day 12 const day12s = await prisma.trackDay.findMany({ where: { dayNumber: 12 } }); let day12Fixed = 0; for (const day of day12s) { let badges: string[] = []; if (day.badges) { try { badges = typeof day.badges === 'string' ? JSON.parse(day.badges as string) : day.badges as string[]; } catch (e) { // Ignore parse errors if somehow invalid } } if (!badges.includes("PITCH_DECK") && !badges.includes("PITCH_AI") && !badges.includes("DOCUMENT_GENERATION")) { badges.push("PITCH_AI"); await prisma.trackDay.update({ where: { id: day.id }, data: { badges } }); console.log(`✅ Fixed badges for ${day.trackId} Day 12: added PITCH_AI`); day12Fixed++; } } // 2. Fix empty activityLabel in BusinessProfiles to avoid Pitch Card crashes const profiles = await prisma.businessProfile.findMany({ where: { OR: [ { activityLabel: null }, { activityLabel: "" } ] }, include: { user: true } }); let profileFixed = 0; for (const profile of profiles) { let label = profile.activityLabel; if (!label || label.trim() === "") { label = profile.user?.activity || "Projet Entrepreneurial"; await prisma.businessProfile.update({ where: { id: profile.id }, data: { activityLabel: label } }); console.log(`✅ Fixed activityLabel for user ${profile.userId} -> ${label}`); profileFixed++; } } console.log(`\n🎉 Bilan des corrections :`); console.log(`- ${day12Fixed} Jours 12 mis à jour avec la métadonnée PITCH_AI`); console.log(`- ${profileFixed} Profils complétés avec une activityLabel par défaut`); await prisma.$disconnect(); } fixAnomalies().catch(e => { console.error(e); process.exit(1); });