From c42cc92bc5c49eba89b6b319318cd12e8b16c2d2 Mon Sep 17 00:00:00 2001 From: billlzzz10 <208072329+billlzzz10@users.noreply.github.com> Date: Thu, 2 Jul 2026 17:48:00 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20CSV=20import?= =?UTF-8?q?=20N+1=20query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Pre-fetch existing prompt titles from CSV batch - Use Set for O(1) lookups during iteration - Add newly processed titles to Set to avoid inserting duplicates from CSV - Reduce DB queries from O(N) to O(1) batched query Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .jules/bolt.md | Bin 2403 -> 3072 bytes src/app/api/admin/import-prompts/route.ts | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index 02deaebaddd04f8732f1410ff5dc6f70a9ede6d9..4c327a6ba111cfcc292befc5210283134808e2c7 100644 GIT binary patch delta 682 zcmXw%L2uJQ5QWd=$cf_PVP|LFy!WmDJ^%CKZ~bhXU0h(h*}h(F-mErTtZ;3l?x?|SqHtn+4{`8;4rB#4 zuP&!LQ-rhlc#Y3CQV@1F&Ss0n7c#->%-h8RzdEwu^R=oBsTcM=A-H42v77M-|n19Pgcju4C1QJOfrV=fmSUkQkcF+viy(;y3Go=Oks>@)jFips`W|G z7%?cQyf0B*g4YB~*J7dCIFe3@Tk+Ew#5n@+wbL%T(1@40!?Tw8^PU t{OC9;uO`*{u*!6wRFa3BZ~~n@KB9h!Z^h+&5`O&2;v}8 r.act).filter(Boolean))); + + const existingPrompts = await db.prompt.findMany({ + where: { title: { in: uniqueTitles } }, + select: { title: true }, + }); + + // Create a Set for O(1) lookups during iteration + const existingTitlesSet = new Set(existingPrompts.map((p) => p.title)); + for (const row of rows) { try { // Check if prompt with same title already exists - const existing = await db.prompt.findFirst({ - where: { title: row.act }, - }); - - if (existing) { + if (existingTitlesSet.has(row.act)) { skipped++; continue; } + // Add newly processed title to Set to prevent inserting duplicates from the CSV itself + existingTitlesSet.add(row.act); + // Get or create contributor user const authorId = await getOrCreateContributor(row.contributor); From 393340cabf300d58d5c6dc98258805e549e9d09f Mon Sep 17 00:00:00 2001 From: billlzzz10 <208072329+billlzzz10@users.noreply.github.com> Date: Thu, 2 Jul 2026 17:55:23 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Guardian:=20Fix=20P?= =?UTF-8?q?risma=20CI=20build=20environment=20resolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Map DATABASE_URL to DIRECT_URL during CI schema build steps when DIRECT_URL is missing - Remove static placeholder URL from datasource block to avoid hanging deployment steps Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- prisma.config.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/prisma.config.ts b/prisma.config.ts index 4cc9297d..892e990a 100644 --- a/prisma.config.ts +++ b/prisma.config.ts @@ -3,14 +3,20 @@ import "dotenv/config"; import { defineConfig } from "prisma/config"; +// 🛡️ Guardian: Fix Prisma CI build environment resolution +// JULES Check: Prevents hanging schemas when DATABASE_URL is missing +// Impact: Fixes build pipeline validation errors +// Date: 2024-07-02 +// Session: N/A + +if (process.env.DATABASE_URL && !process.env.DIRECT_URL) { + process.env.DIRECT_URL = process.env.DATABASE_URL; +} + export default defineConfig({ schema: "prisma/schema.prisma", migrations: { path: "prisma/migrations", }, engine: "classic", - datasource: { - url: - process.env.DATABASE_URL ?? "postgresql://placeholder:placeholder@localhost:5432/placeholder", - }, }); From 1139898941e53eb8784382336b2cdddb6d2de8ac Mon Sep 17 00:00:00 2001 From: billlzzz10 <208072329+billlzzz10@users.noreply.github.com> Date: Thu, 2 Jul 2026 18:07:39 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Guardian:=20Fix=20P?= =?UTF-8?q?risma=20CI=20build=20environment=20resolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add DATABASE_URL to DIRECT_URL fallback for CI builds to prevent hanging deployments - Define empty datasource URL block correctly to satisfy SchemaEngineConfigClassic type requirements - Use non-null assertion to satisfy typescript without hardcoding a dummy database placeholder Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- prisma.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prisma.config.ts b/prisma.config.ts index 892e990a..1cf64a67 100644 --- a/prisma.config.ts +++ b/prisma.config.ts @@ -19,4 +19,8 @@ export default defineConfig({ path: "prisma/migrations", }, engine: "classic", + datasource: { + // Non-null assertion strictly for typing, avoiding the fake placeholder URL that causes deployment hangs + url: process.env.DATABASE_URL!, + }, });