initial push

This commit is contained in:
Sone
2026-05-19 18:44:42 +02:00
parent f467a59da1
commit 957f583a71
7 changed files with 1108 additions and 1700 deletions
+10 -4
View File
@@ -6,6 +6,8 @@ import {
PriorityStatus,
SecurityType,
} from "@prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";
import pg from "pg";
import bcrypt from "bcryptjs";
import {
@@ -46,7 +48,11 @@ const uniqueTask = (idx: number) => {
return `${sentenceFrom(idx)}\n\nContext: ${hint} [T${idx + 1}]`;
};
const prisma = new PrismaClient();
const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
});
const adapter = new PrismaPg(pool, { schema: "Athena" });
const prisma = new PrismaClient({ adapter });
const getRandom = <T>(arr: T[]): T =>
arr[Math.floor(Math.random() * arr.length)];
@@ -199,19 +205,19 @@ async function main() {
let todoIndex = 0;
const createTeamTodo = async (
team: Array<Awaited<ReturnType<typeof prisma.user.create>>>
team: Array<Awaited<ReturnType<typeof prisma.user.create>>>,
) => {
const createdByUser = getRandom(team);
// 1-3 assignees from the same team (ensure createdBy is included)
const baseAssignees = pickSubset(
team,
1 + Math.floor(Math.random() * Math.min(3, team.length))
1 + Math.floor(Math.random() * Math.min(3, team.length)),
);
const ensureCreatedBy = baseAssignees.some((u) => u.id === createdByUser.id)
? baseAssignees
: [...baseAssignees, createdByUser];
const uniqueAssignees = Array.from(
new Map(ensureCreatedBy.map((u) => [u.id, u])).values()
new Map(ensureCreatedBy.map((u) => [u.id, u])).values(),
);
const dueDate = new Date();