From 5abfe81fabb8663aefea4d80a8b13bc60c1537a3 Mon Sep 17 00:00:00 2001 From: ZeeLyn Date: Thu, 18 Sep 2025 15:09:01 +0800 Subject: [PATCH 1/3] Response error when the dataset exists Prevent data sets from overwriting --- ui/src/app/api/datasets/create/route.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/src/app/api/datasets/create/route.tsx b/ui/src/app/api/datasets/create/route.tsx index ac4d290ad..7afb07eb0 100644 --- a/ui/src/app/api/datasets/create/route.tsx +++ b/ui/src/app/api/datasets/create/route.tsx @@ -13,10 +13,11 @@ export async function POST(request: Request) { let datasetsPath = await getDatasetsRoot(); let datasetPath = path.join(datasetsPath, name); - // if folder doesnt exist, create it - if (!fs.existsSync(datasetPath)) { - fs.mkdirSync(datasetPath); + if (fs.existsSync(datasetPath)) { + return NextResponse.json({ error: 'Dataset already exists' }, { status: 500 }); } + // if folder doesnt exist, create it + fs.mkdirSync(datasetPath); return NextResponse.json({ success: true, name: name }); } catch (error) { From aef493304eeb0284244a7a2d8c2ccdff67f8836f Mon Sep 17 00:00:00 2001 From: ZeeLyn Date: Fri, 19 Sep 2025 21:29:09 +0800 Subject: [PATCH 2/3] /api/jobs add status parameter --- ui/src/app/api/jobs/route.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/src/app/api/jobs/route.ts b/ui/src/app/api/jobs/route.ts index c489088d7..c670d2722 100644 --- a/ui/src/app/api/jobs/route.ts +++ b/ui/src/app/api/jobs/route.ts @@ -6,6 +6,7 @@ const prisma = new PrismaClient(); export async function GET(request: Request) { const { searchParams } = new URL(request.url); const id = searchParams.get('id'); + const status = searchParams.get('status'); try { if (id) { @@ -14,8 +15,13 @@ export async function GET(request: Request) { }); return NextResponse.json(job); } + let where = {}; + if (status) { + where['status'] = status; + } const jobs = await prisma.job.findMany({ + where: where, orderBy: { created_at: 'desc' }, }); return NextResponse.json({ jobs: jobs }); From 3a405fb0099802d0757f2028402020c11dc56be2 Mon Sep 17 00:00:00 2001 From: ZeeLyn Date: Fri, 19 Sep 2025 21:38:44 +0800 Subject: [PATCH 3/3] /api/jobs add status parameter --- ui/src/app/api/jobs/route.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/src/app/api/jobs/route.ts b/ui/src/app/api/jobs/route.ts index c670d2722..d5324be87 100644 --- a/ui/src/app/api/jobs/route.ts +++ b/ui/src/app/api/jobs/route.ts @@ -1,5 +1,8 @@ import { NextResponse } from 'next/server'; import { PrismaClient } from '@prisma/client'; +interface JobWhereClause { + status?: string; +} const prisma = new PrismaClient(); @@ -15,9 +18,9 @@ export async function GET(request: Request) { }); return NextResponse.json(job); } - let where = {}; + let where: JobWhereClause = {}; if (status) { - where['status'] = status; + where.status = status; } const jobs = await prisma.job.findMany({