From b816cbe7107432737f8cfd27bd6626f70fd6c20d Mon Sep 17 00:00:00 2001 From: Scrum4Me Agent <30029041+madhura68@users.noreply.github.com> Date: Thu, 14 May 2026 16:16:56 +0200 Subject: [PATCH] refactor(ordering): remove priority from all story/task orderBy Story- en taak-ordering is nu puur sort_order asc (created_at als tiebreaker). PBI-ordering (priority + sort_order) blijft ongewijzigd. Gewijzigd: backlog/route, pbis/stories/route, claude-context/route, next-story/route, workspace/route, tasks/route, sprint-runs (query + in-memory sort), solo-workspace-server, page.tsx (app + mobile + sprint), store compareStory, actions/sprints story-query, next-story test. Co-Authored-By: Claude Sonnet 4.6 --- __tests__/api/next-story.test.ts | 4 ++-- actions/sprint-runs.ts | 5 ++--- actions/sprints.ts | 2 +- app/(app)/products/[id]/page.tsx | 4 ++-- app/(app)/products/[id]/sprint/[sprintId]/page.tsx | 4 ++-- app/(mobile)/m/products/[id]/page.tsx | 4 ++-- app/api/pbis/[id]/stories/route.ts | 2 +- app/api/products/[id]/backlog/route.ts | 2 +- app/api/products/[id]/claude-context/route.ts | 2 +- app/api/products/[id]/next-story/route.ts | 2 +- app/api/sprints/[id]/tasks/route.ts | 1 - app/api/sprints/[id]/workspace/route.ts | 2 +- lib/solo-workspace-server.ts | 3 +-- stores/sprint-workspace/store.ts | 1 - 14 files changed, 17 insertions(+), 21 deletions(-) diff --git a/__tests__/api/next-story.test.ts b/__tests__/api/next-story.test.ts index 4c614e9..fc549d8 100644 --- a/__tests__/api/next-story.test.ts +++ b/__tests__/api/next-story.test.ts @@ -95,7 +95,7 @@ describe('GET /api/products/:id/next-story', () => { expect(data.tasks[0]).toMatchObject({ id: 'task-1', status: 'todo' }) }) - it('queries story ordered by priority then sort_order', async () => { + it('queries story ordered by sort_order only', async () => { mockPrisma.sprint.findFirst.mockResolvedValue(SPRINT) mockPrisma.story.findFirst.mockResolvedValue(STORY) @@ -103,7 +103,7 @@ describe('GET /api/products/:id/next-story', () => { expect(mockPrisma.story.findFirst).toHaveBeenCalledWith( expect.objectContaining({ - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], }) ) }) diff --git a/actions/sprint-runs.ts b/actions/sprint-runs.ts index a08118b..8b232d0 100644 --- a/actions/sprint-runs.ts +++ b/actions/sprint-runs.ts @@ -85,10 +85,10 @@ async function startSprintRunCore( // TO_DO, dus EXCLUDED/IN_PROGRESS/REVIEW/DONE/FAILED tasks komen niet // terecht in pre-flight blockers, jobs of SprintTaskExecution-rijen. where: { status: 'TO_DO' }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], }, }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], }) const blockers: PreFlightBlocker[] = [] @@ -167,7 +167,6 @@ async function startSprintRunCore( (a, b) => a.pbi.priority - b.pbi.priority || a.pbi.sort_order - b.pbi.sort_order || - a.priority - b.priority || a.sort_order - b.sort_order, ) .flatMap((s) => s.tasks) diff --git a/actions/sprints.ts b/actions/sprints.ts index fd44ff0..eb627a5 100644 --- a/actions/sprints.ts +++ b/actions/sprints.ts @@ -431,7 +431,7 @@ export async function createSprintAction(_prevState: unknown, formData: FormData if (pbi) { const stories = await prisma.story.findMany({ where: { pbi_id: pbi.id, sprint_id: null }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], select: { id: true }, }) if (stories.length > 0) { diff --git a/app/(app)/products/[id]/page.tsx b/app/(app)/products/[id]/page.tsx index d63fbec..5157b73 100644 --- a/app/(app)/products/[id]/page.tsx +++ b/app/(app)/products/[id]/page.tsx @@ -56,7 +56,7 @@ export default async function ProductBacklogPage({ params, searchParams }: Props const [stories, tasks] = await Promise.all([ prisma.story.findMany({ where: { product_id: id }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }], select: { id: true, code: true, @@ -84,7 +84,7 @@ export default async function ProductBacklogPage({ params, searchParams }: Props story_id: true, created_at: true, }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }], }), ]) diff --git a/app/(app)/products/[id]/sprint/[sprintId]/page.tsx b/app/(app)/products/[id]/sprint/[sprintId]/page.tsx index 992c217..2981c47 100644 --- a/app/(app)/products/[id]/sprint/[sprintId]/page.tsx +++ b/app/(app)/products/[id]/sprint/[sprintId]/page.tsx @@ -72,7 +72,7 @@ export default async function SprintBoardPage({ params, searchParams }: Props) { where: { sprint_id: sprint.id }, orderBy: { sort_order: 'asc' }, include: { - tasks: { orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }] }, + tasks: { orderBy: [{ sort_order: 'asc' }] }, assignee: { select: { id: true, username: true } }, }, }), @@ -128,7 +128,7 @@ export default async function SprintBoardPage({ params, searchParams }: Props) { orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], include: { stories: { - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], }, }, }) diff --git a/app/(mobile)/m/products/[id]/page.tsx b/app/(mobile)/m/products/[id]/page.tsx index 25331b6..4aa5815 100644 --- a/app/(mobile)/m/products/[id]/page.tsx +++ b/app/(mobile)/m/products/[id]/page.tsx @@ -42,7 +42,7 @@ export default async function MobileProductBacklogPage({ params, searchParams }: const [stories, tasks] = await Promise.all([ prisma.story.findMany({ where: { product_id: id }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }], select: { id: true, code: true, @@ -70,7 +70,7 @@ export default async function MobileProductBacklogPage({ params, searchParams }: story_id: true, created_at: true, }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }], }), ]) diff --git a/app/api/pbis/[id]/stories/route.ts b/app/api/pbis/[id]/stories/route.ts index 8cb760b..67de693 100644 --- a/app/api/pbis/[id]/stories/route.ts +++ b/app/api/pbis/[id]/stories/route.ts @@ -30,7 +30,7 @@ export async function GET( const stories = await prisma.story.findMany({ where: { pbi_id: id }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }, { created_at: 'asc' }], + orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }], select: { id: true, code: true, diff --git a/app/api/products/[id]/backlog/route.ts b/app/api/products/[id]/backlog/route.ts index e187edb..9badc35 100644 --- a/app/api/products/[id]/backlog/route.ts +++ b/app/api/products/[id]/backlog/route.ts @@ -46,7 +46,7 @@ export async function GET( }), prisma.story.findMany({ where: { product_id: id }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }, { created_at: 'asc' }], + orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }], select: { id: true, code: true, diff --git a/app/api/products/[id]/claude-context/route.ts b/app/api/products/[id]/claude-context/route.ts index 3611c64..556d6d7 100644 --- a/app/api/products/[id]/claude-context/route.ts +++ b/app/api/products/[id]/claude-context/route.ts @@ -58,7 +58,7 @@ export async function GET( if (activeSprint) { const story = await prisma.story.findFirst({ where: { sprint_id: activeSprint.id, status: 'IN_SPRINT' }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], include: { tasks: { orderBy: { sort_order: 'asc' }, diff --git a/app/api/products/[id]/next-story/route.ts b/app/api/products/[id]/next-story/route.ts index 4ab4529..f2dd414 100644 --- a/app/api/products/[id]/next-story/route.ts +++ b/app/api/products/[id]/next-story/route.ts @@ -23,7 +23,7 @@ export async function GET( const story = await prisma.story.findFirst({ where: { sprint_id: sprint.id, status: 'IN_SPRINT' }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], include: { tasks: { orderBy: { sort_order: 'asc' }, diff --git a/app/api/sprints/[id]/tasks/route.ts b/app/api/sprints/[id]/tasks/route.ts index 6d1e2d3..73f88c0 100644 --- a/app/api/sprints/[id]/tasks/route.ts +++ b/app/api/sprints/[id]/tasks/route.ts @@ -28,7 +28,6 @@ export async function GET( where: { sprint_id: id }, orderBy: [ { story: { sort_order: 'asc' } }, - { priority: 'asc' }, { sort_order: 'asc' }, ], take: limit, diff --git a/app/api/sprints/[id]/workspace/route.ts b/app/api/sprints/[id]/workspace/route.ts index e3a19ab..8d48c7d 100644 --- a/app/api/sprints/[id]/workspace/route.ts +++ b/app/api/sprints/[id]/workspace/route.ts @@ -44,7 +44,7 @@ export async function GET( const [stories, tasks] = await Promise.all([ prisma.story.findMany({ where: { sprint_id: id }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }, { created_at: 'asc' }], + orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }], include: { tasks: { select: { id: true, status: true } }, assignee: { select: { id: true, username: true } }, diff --git a/lib/solo-workspace-server.ts b/lib/solo-workspace-server.ts index 01e2329..7c8a42c 100644 --- a/lib/solo-workspace-server.ts +++ b/lib/solo-workspace-server.ts @@ -46,7 +46,6 @@ export async function getSoloWorkspaceSnapshot( { story: { pbi: { priority: 'asc' } } }, { story: { pbi: { sort_order: 'asc' } } }, { story: { sort_order: 'asc' } }, - { priority: 'asc' }, { sort_order: 'asc' }, ], }), @@ -58,7 +57,7 @@ export async function getSoloWorkspaceSnapshot( title: true, tasks: { select: { id: true, title: true, description: true, priority: true, status: true }, - orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }], + orderBy: [{ sort_order: 'asc' }], }, }, orderBy: { sort_order: 'asc' }, diff --git a/stores/sprint-workspace/store.ts b/stores/sprint-workspace/store.ts index 81e878f..c33ff2b 100644 --- a/stores/sprint-workspace/store.ts +++ b/stores/sprint-workspace/store.ts @@ -146,7 +146,6 @@ function compareSprint(a: SprintWorkspaceSprint, b: SprintWorkspaceSprint): numb } function compareStory(a: SprintWorkspaceStory, b: SprintWorkspaceStory): number { - if (a.priority !== b.priority) return a.priority - b.priority if (a.sort_order !== b.sort_order) return a.sort_order - b.sort_order return new Date(a.created_at).getTime() - new Date(b.created_at).getTime() }