feat: Initial Diabetix application commit
- Add authentication with NextAuth v5 (credentials + email verification) - Implement dashboard with glycemia tracking and AI analysis - Add PDF report generation for Premium users - Implement Stripe integration for Premium subscriptions - Add responsive UI with Tailwind CSS and shadcn components - Database schema with Prisma ORM and PostgreSQL support - Real-time glycemia visualization with Recharts - Mobile-optimized entry form - User profile management with medical information - Subscription lifecycle management (create, cancel, webhook) - Email notifications with Resend - Feature gates for Free vs Premium plans Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
51
prisma/seed.ts
Normal file
51
prisma/seed.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import path from "node:path";
|
||||
import { PrismaClient } from "../src/generated/prisma/client";
|
||||
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
|
||||
import "dotenv/config";
|
||||
|
||||
const databaseUrl =
|
||||
process.env.DATABASE_URL ?? `file:${path.resolve("prisma/dev.db")}`;
|
||||
|
||||
const prisma = new PrismaClient({
|
||||
adapter: new PrismaBetterSqlite3({ url: databaseUrl }),
|
||||
});
|
||||
|
||||
const moments = [
|
||||
{ key: "FASTING", hour: 7, baseMin: 0.85, baseMax: 1.25 },
|
||||
{ key: "LUNCH", hour: 14, baseMin: 1.05, baseMax: 1.75 },
|
||||
{ key: "DINNER", hour: 21, baseMin: 1.0, baseMax: 1.7 },
|
||||
] as const;
|
||||
|
||||
function rand(min: number, max: number) {
|
||||
return min + Math.random() * (max - min);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await prisma.reading.deleteMany();
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const data: { measuredAt: Date; moment: string; value: number; notes: string | null }[] = [];
|
||||
|
||||
for (let day = 29; day >= 0; day--) {
|
||||
for (const m of moments) {
|
||||
const d = new Date(today.getTime() - day * 86_400_000);
|
||||
d.setHours(m.hour, Math.floor(Math.random() * 30), 0, 0);
|
||||
let value = rand(m.baseMin, m.baseMax);
|
||||
// Quelques valeurs aberrantes pour montrer hypo / hyper
|
||||
if (Math.random() < 0.05) value = rand(0.5, 0.68);
|
||||
if (Math.random() < 0.05) value = rand(1.85, 2.4);
|
||||
data.push({
|
||||
measuredAt: d,
|
||||
moment: m.key,
|
||||
value: Math.round(value * 100) / 100,
|
||||
notes: Math.random() < 0.15 ? "Bonne forme" : null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.reading.createMany({ data });
|
||||
console.log(`✓ ${data.length} relevés générés.`);
|
||||
}
|
||||
|
||||
main().finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user