feat(PBI-59): API route GET /api/jobs/[id]/sub-tasks voor sprint task executions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0669e55175
commit
fa4192a28a
1 changed files with 39 additions and 0 deletions
39
app/api/jobs/[id]/sub-tasks/route.ts
Normal file
39
app/api/jobs/[id]/sub-tasks/route.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import type { NextRequest } from 'next/server'
|
||||
import { getSession } from '@/lib/auth'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
const session = await getSession()
|
||||
if (!session.userId) {
|
||||
return Response.json({ error: 'Niet ingelogd' }, { status: 401 })
|
||||
}
|
||||
const userId = session.userId
|
||||
const { id } = await params
|
||||
|
||||
const job = await prisma.claudeJob.findFirst({
|
||||
where: { id, user_id: userId },
|
||||
select: { kind: true },
|
||||
})
|
||||
|
||||
if (!job || job.kind !== 'SPRINT_IMPLEMENTATION') {
|
||||
return Response.json([], { status: 200 })
|
||||
}
|
||||
|
||||
const executions = await prisma.sprintTaskExecution.findMany({
|
||||
where: { sprint_job_id: id },
|
||||
include: { task: { select: { code: true, title: true } } },
|
||||
orderBy: { order: 'asc' },
|
||||
})
|
||||
|
||||
return Response.json(
|
||||
executions.map(e => ({
|
||||
id: e.id,
|
||||
taskCode: e.task.code,
|
||||
taskTitle: e.task.title,
|
||||
status: e.status,
|
||||
}))
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue