- tsconfig: remove deprecated downlevelIteration (es2017 has native iterators), change moduleResolution from node to bundler - auth: set allowDangerousEmailAccountLinking=false on all OAuth providers, restrict debug mode to development only - prisma: replace new PrismaClient() with singleton import in 10 API routes to prevent connection pool exhaustion - goal API: validate user-supplied quote URLs to block SSRF (private IPs, non-http(s) schemes) - email: guard DEV verification/reset link console.logs behind NODE_ENV check v1.98.0
154 lines
5.6 KiB
TypeScript
154 lines
5.6 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
const prisma = new PrismaClient();
|
|
|
|
const dailyTasks = [
|
|
"Pretend to listen to partner's work drama",
|
|
"Feed the kids (again? really?)",
|
|
"Hide Amazon packages from spouse",
|
|
"Attempt to fold a fitted sheet, give up and roll it into a ball",
|
|
"Cook a meal that exactly 0% of the family will appreciate",
|
|
"Look at the mess. Sigh. Walk away.",
|
|
"Move the laundry from washer to dryer, leave it there for 3 days",
|
|
"Find out what died in the fridge",
|
|
"Pay bills and cry softly",
|
|
"Unload dishwasher with immense resentment",
|
|
"Scroll on phone until legs go numb on the toilet",
|
|
"Perform archeological dig in the teenage bedroom",
|
|
"Interrogate child about missing tupperware lid",
|
|
"Nod enthusiastically at toddler's incomprehensible story",
|
|
"Try to decipher spouse's 'helpful' grocery list",
|
|
"Pretend I don't see the full trash can"
|
|
];
|
|
|
|
const workEvents = [
|
|
"Meaningless sync meeting #42",
|
|
"Stare blankly at spreadsheet",
|
|
"Listen to boss talk about synergy",
|
|
"Reply 'As per my previous email...' to Gary",
|
|
"Pretend to be busy so no one asks me for help",
|
|
"'Quick chat' that ruins my entire afternoon",
|
|
"Update Jira tickets to make it look like I did something",
|
|
"Mute mic and eat aggressively loud chips during all-hands",
|
|
"Consider moving to the woods and becoming a hermit",
|
|
"Frantically search for the tab that is playing music"
|
|
];
|
|
|
|
const birthdayTasks = [
|
|
"Buy a gift that makes me look thoughtful but was actually on sale",
|
|
"Wrap the present (using newspaper because I forgot wrapping paper)",
|
|
"Attend birthday party and strategically position myself near the snack table",
|
|
"Fake a smile while listening to Uncle Bob's views",
|
|
"Smuggle leftover cake home in napkins"
|
|
];
|
|
|
|
async function main() {
|
|
const user = await prisma.user.findUnique({
|
|
where: { email: 'kugelblitz@gmx.de' }
|
|
});
|
|
|
|
if (!user) {
|
|
console.log("User kugelblitz@gmx.de not found in database.");
|
|
return;
|
|
}
|
|
console.log(`Using user: ${user.email} (${user.id})`);
|
|
|
|
// Target dates: March 16 to April 12, 2026
|
|
const startDate = new Date('2026-03-16T00:00:00Z');
|
|
const endDate = new Date('2026-04-12T00:00:00Z');
|
|
|
|
// Birthday party around April 4th
|
|
const birthdayDate = new Date('2026-04-04T00:00:00Z');
|
|
|
|
// April Fools on April 1st
|
|
const aprilFools = new Date('2026-04-01T00:00:00Z');
|
|
|
|
for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
|
|
// ~40% fill rate for normal days
|
|
const isBirthday = d.getTime() === birthdayDate.getTime();
|
|
const isAprilFools = d.getTime() === aprilFools.getTime();
|
|
|
|
// Skip ~60% of the regular days to keep density 30-50%
|
|
if (!isBirthday && !isAprilFools && Math.random() > 0.45) {
|
|
continue;
|
|
}
|
|
|
|
const dateStr = d.toISOString().split('T')[0];
|
|
const isWeekend = d.getDay() === 0 || d.getDay() === 6;
|
|
|
|
// Add 1-2 daily tasks (without specific time)
|
|
const numTasks = Math.floor(Math.random() * 2) + 1;
|
|
for (let i = 0; i < numTasks; i++) {
|
|
const taskName = dailyTasks[Math.floor(Math.random() * dailyTasks.length)];
|
|
await prisma.task.create({
|
|
data: {
|
|
title: taskName,
|
|
userId: user.id,
|
|
scheduledDate: new Date(dateStr),
|
|
dayOfWeek: d.getDay(),
|
|
order: i,
|
|
}
|
|
});
|
|
}
|
|
|
|
// Add 1-2 work events (with time) if it's a weekday
|
|
if (!isWeekend) {
|
|
if (Math.random() > 0.3) {
|
|
const numEvents = Math.floor(Math.random() * 2) + 1;
|
|
let currentHour = Math.floor(Math.random() * (11 - 8 + 1)) + 8; // Morning 8-11
|
|
|
|
for (let e = 0; e < numEvents; e++) {
|
|
const eventName = workEvents[Math.floor(Math.random() * workEvents.length)];
|
|
const startTime = `${currentHour.toString().padStart(2, '0')}:00`;
|
|
await prisma.task.create({
|
|
data: {
|
|
title: eventName,
|
|
userId: user.id,
|
|
scheduledDate: new Date(dateStr),
|
|
dayOfWeek: d.getDay(),
|
|
startTime: startTime,
|
|
endTime: `${(currentHour+1).toString().padStart(2, '0')}:00`,
|
|
}
|
|
});
|
|
currentHour += Math.floor(Math.random() * 3) + 2; // Jump 2-4 hours for next event
|
|
if (currentHour > 17) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add April Fools extra
|
|
if (isAprilFools) {
|
|
await prisma.task.create({
|
|
data: {
|
|
title: "Attempt a prank, fail miserably, apologize to HR",
|
|
userId: user.id,
|
|
scheduledDate: new Date(dateStr),
|
|
dayOfWeek: d.getDay(),
|
|
startTime: "10:30",
|
|
endTime: "11:00",
|
|
}
|
|
});
|
|
}
|
|
|
|
// Add Birthday extras
|
|
if (isBirthday) {
|
|
for (let i = 0; i < birthdayTasks.length; i++) {
|
|
const time = i >= 2 ? `${14 + i}:00` : undefined; // Party elements have times 16:00, 17:00, 18:00
|
|
await prisma.task.create({
|
|
data: {
|
|
title: birthdayTasks[i],
|
|
userId: user.id,
|
|
scheduledDate: new Date(dateStr),
|
|
dayOfWeek: d.getDay(),
|
|
startTime: time,
|
|
endTime: time ? `${15 + i}:00` : undefined,
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log("Successfully seeded the calendar with fun, sarcastic data!");
|
|
}
|
|
|
|
main().catch(console.error).finally(() => prisma.$disconnect());
|