Download apps/api/src/scripts/fix-qa-anomalies.ts from safetrack/edtech: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/spaces/safetrack/edtech/resolve/main/apps/api/src/scripts/fix-qa-anomalies.ts
- Command line
-
hf download hf://spaces/safetrack/edtech/apps/api/src/scripts/fix-qa-anomalies.ts
-
curl -L -o fix-qa-anomalies.ts https://huggingface.co/spaces/safetrack/edtech/resolve/main/apps/api/src/scripts/fix-qa-anomalies.ts
2.25 kB
| import { PrismaClient } from '@prisma/client'; | |
| const prisma = new PrismaClient(); | |
| async function fixAnomalies() { | |
| console.log("๐ ๏ธ Starting QA anomalies fix..."); | |
| // 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๐ 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); | |
| }); | |