From b5d08f73a795fb554ddaf0926f2ee23280796c97 Mon Sep 17 00:00:00 2001 From: Din Date: Mon, 6 Jan 2025 18:34:55 +0500 Subject: [PATCH] fix: allow removing item from queue if no labels --- .../queues/[queueId]/remove/route.ts | 20 ++++++++++--------- .../api/projects/[projectId]/queues/route.ts | 2 -- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts b/frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts index bc5f2623..264b8d80 100644 --- a/frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts +++ b/frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts @@ -30,7 +30,7 @@ const removeQueueItemSchema = z.object({ id: z.string() }), reasoning: z.string().optional().nullable() - })).nonempty(), + })), action: z.null().or(z.object({ resultId: z.string().optional(), datasetId: z.string().optional() @@ -61,14 +61,16 @@ export async function POST(request: Request, { params }: { params: { projectId: labelSource: "MANUAL" as const, })); - const insertedLabels = await db.insert(labels).values(newLabels).onConflictDoUpdate({ - target: [labels.spanId, labels.classId, labels.userId], - set: { - value: sql`excluded.value`, - labelSource: sql`excluded.label_source`, - reasoning: sql`COALESCE(excluded.reasoning, labels.reasoning)`, - } - }).returning(); + const insertedLabels = newLabels.length > 0 + ? await db.insert(labels).values(newLabels).onConflictDoUpdate({ + target: [labels.spanId, labels.classId, labels.userId], + set: { + value: sql`excluded.value`, + labelSource: sql`excluded.label_source`, + reasoning: sql`COALESCE(excluded.reasoning, labels.reasoning)`, + } + }).returning() + : []; if (action?.resultId) { const resultId = action.resultId; diff --git a/frontend/app/api/projects/[projectId]/queues/route.ts b/frontend/app/api/projects/[projectId]/queues/route.ts index 3324a92a..82f8139b 100644 --- a/frontend/app/api/projects/[projectId]/queues/route.ts +++ b/frontend/app/api/projects/[projectId]/queues/route.ts @@ -11,8 +11,6 @@ export async function POST( ): Promise { const projectId = params.projectId; - - const body = await req.json(); const { name } = body;