- Sprint lifecycle: ACTIVE→OPEN, COMPLETED→CLOSED, +ARCHIVED (FAILED behouden) - TaskStatus: +EXCLUDED (overgeslagen door agent-loop via bestaande TO_DO filter) - Cookie-gebaseerde actieve sprint per product (lib/active-sprint.ts) - Route splitsen: /products/[id]/sprint/[sprintId] + /sprint redirect-page - NavBar: gestapelde product/sprint dropdowns + BUILDING-badge derivatie - Backlog selectie-modus + nieuwe-sprint-dialog (createSprintWithPbisAction) - Migratie 20260507210000_sprint_lifecycle: ALTER TYPE RENAME (geen data-rewrite) - Version bump 1.0.0 → 1.2.0 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { prisma } from '@/lib/prisma'
|
|
import { productAccessFilter } from '@/lib/product-access'
|
|
|
|
export type SprintStatusGroup = 'TO_DO' | 'IN_PROGRESS' | 'DONE'
|
|
|
|
export interface StatusCount {
|
|
status: SprintStatusGroup
|
|
count: number
|
|
}
|
|
|
|
// Maps REVIEW → IN_PROGRESS so donut shows 3 buckets only
|
|
function toGroup(status: string): SprintStatusGroup {
|
|
if (status === 'DONE') return 'DONE'
|
|
if (status === 'TO_DO') return 'TO_DO'
|
|
return 'IN_PROGRESS'
|
|
}
|
|
|
|
export async function getSprintStatusBreakdown(userId: string): Promise<StatusCount[]> {
|
|
const tasks = await prisma.task.findMany({
|
|
where: {
|
|
story: {
|
|
sprint: {
|
|
status: 'OPEN',
|
|
product: productAccessFilter(userId),
|
|
},
|
|
},
|
|
},
|
|
select: { status: true },
|
|
})
|
|
|
|
const counts: Record<SprintStatusGroup, number> = { TO_DO: 0, IN_PROGRESS: 0, DONE: 0 }
|
|
for (const t of tasks) {
|
|
counts[toGroup(t.status)]++
|
|
}
|
|
|
|
return (Object.entries(counts) as [SprintStatusGroup, number][])
|
|
.filter(([, count]) => count > 0)
|
|
.map(([status, count]) => ({ status, count }))
|
|
}
|