const { PrismaClient } = require("@prisma/client"); const prisma = new PrismaClient(); async function main() { const user = await prisma.user.findUnique({ where: { email: "testuser@example.com" } }); if (!user) { console.log("User not found"); process.exit(1); } // Generate sample readings for the past 12 months const readings = []; const today = new Date(); for (let monthsAgo = 0; monthsAgo < 12; monthsAgo++) { const monthDate = new Date(today.getFullYear(), today.getMonth() - monthsAgo, 1); const daysInMonth = new Date(monthDate.getFullYear(), monthDate.getMonth() + 1, 0).getDate(); for (let day = 1; day <= daysInMonth; day += 2) { // Every 2 days for (let time = 0; time < 3; time++) { // 3 times per day readings.push({ userId: user.id, value: Math.floor(Math.random() * 150) + 60, // 60-210 mg/dL measuredAt: new Date(monthDate.getFullYear(), monthDate.getMonth(), day, 6 + time * 8, 0), notes: time === 0 ? "Avant petit-déjeuner" : time === 1 ? "Avant déjeuner" : "Avant dîner" }); } } } await prisma.reading.createMany({ data: readings, skipDuplicates: true }); console.log(`Created ${readings.length} readings`); await prisma.$disconnect(); } main().catch(console.error);