- lib/job-status.ts: SKIPPED ↔ 'skipped' mapping in beide richtingen - components/shared/job-status.ts: label "Overgeslagen" + neutrale italic styling - actions/admin/jobs.ts: cancel-guard erkent SKIPPED als eindstatus - app/api/cron/cleanup-agent-artifacts: SKIPPED ook opruimen na 7d - lib/insights/agent-throughput: SKIPPED telt mee als terminal ACTIVE_JOB_STATUSES bewust ongewijzigd — SKIPPED is afgerond. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
'use server'
|
|
|
|
import { revalidatePath } from 'next/cache'
|
|
import { z } from 'zod'
|
|
import { prisma } from '@/lib/prisma'
|
|
import { requireAdmin } from '@/lib/auth-guard'
|
|
|
|
const cuidSchema = z.string().cuid()
|
|
|
|
export async function cancelJobAction(jobId: string) {
|
|
await requireAdmin()
|
|
|
|
const parsed = cuidSchema.safeParse(jobId)
|
|
if (!parsed.success) throw new Error('Ongeldig job-id')
|
|
|
|
const job = await prisma.claudeJob.findUnique({
|
|
where: { id: parsed.data },
|
|
select: { status: true },
|
|
})
|
|
|
|
if (!job) throw new Error('Job niet gevonden')
|
|
if (job.status === 'DONE' || job.status === 'FAILED' || job.status === 'CANCELLED' || job.status === 'SKIPPED') {
|
|
throw new Error('Job is al in eindstatus')
|
|
}
|
|
|
|
await prisma.claudeJob.update({
|
|
where: { id: parsed.data },
|
|
data: { status: 'CANCELLED', finished_at: new Date() },
|
|
})
|
|
revalidatePath('/admin/jobs')
|
|
}
|
|
|
|
export async function deleteJobAction(jobId: string) {
|
|
await requireAdmin()
|
|
|
|
const parsed = cuidSchema.safeParse(jobId)
|
|
if (!parsed.success) throw new Error('Ongeldig job-id')
|
|
|
|
await prisma.claudeJob.delete({ where: { id: parsed.data } })
|
|
revalidatePath('/admin/jobs')
|
|
}
|