From 6f0628eb3b7e58da41222b000f0d7d58957b359f Mon Sep 17 00:00:00 2001 From: Chris <125088905+wyattchris@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:09:41 -0400 Subject: [PATCH] dummy data pt2 --- src/server/api/routers/dummy.ts | 7 ++----- src/server/dummyData.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/server/api/routers/dummy.ts b/src/server/api/routers/dummy.ts index dfa8e92..e5c44b8 100644 --- a/src/server/api/routers/dummy.ts +++ b/src/server/api/routers/dummy.ts @@ -1,13 +1,10 @@ import { z } from "zod"; import dummyCreate from "~/server/dummyData"; -import { - createTRPCRouter, - publicProcedure, - } from "~/server/api/trpc"; +import { createTRPCRouter, publicProcedure } from "~/server/api/trpc"; export const dummy = createTRPCRouter({ - testDummy: publicProcedure + testDummy: publicProcedure .input(z.object({ name: z.string() })) .mutation(async ({ ctx, input }) => { await dummyCreate(); diff --git a/src/server/dummyData.ts b/src/server/dummyData.ts index 806e28a..9b8acb8 100644 --- a/src/server/dummyData.ts +++ b/src/server/dummyData.ts @@ -11,7 +11,9 @@ const openai = new OpenAI({ }); async function generateDummyData(model: string, fields: string[]) { - console.log(`Generating dummy data for model ${model} with fields: ${fields.join(", ")}`); + console.log( + `Generating dummy data for model ${model} with fields: ${fields.join(", ")}`, + ); try { const response = await openai.chat.completions.create({ model: "gpt-3.5-turbo", @@ -57,7 +59,9 @@ async function dummyCreate() { const model = prisma[modelName as keyof typeof prisma]; if (model) { // @ts-ignore - await prisma[modelName.toLocaleLowerCase()].create({ data: JSON.parse(dummyData) }); + await prisma[modelName.toLocaleLowerCase()].create({ + data: JSON.parse(dummyData), + }); console.log(`Data inserted for model ${modelName}`); } else { console.error(