| import { PrismaClient } from '@prisma/client'; |
|
|
| const prisma = new PrismaClient(); |
|
|
| async function fixAnomalies() { |
| console.log("π οΈ Starting QA anomalies fix..."); |
|
|
| |
| 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) { |
| |
| } |
| } |
|
|
| 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++; |
| } |
| } |
|
|
| |
| 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π Correction Summary:`); |
| console.log(`- ${day12Fixed} Day 12s updated with PITCH_AI metadata`); |
| console.log(`- ${profileFixed} Profiles completed with a default activityLabel`); |
|
|
| await prisma.$disconnect(); |
| } |
|
|
| fixAnomalies().catch(e => { |
| console.error(e); |
| process.exit(1); |
| }); |
|
|