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 <noreply@anthropic.com>
This commit is contained in:
parent
86692f8e31
commit
b816cbe710
14 changed files with 17 additions and 21 deletions
|
|
@ -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' }],
|
||||
})
|
||||
)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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' }],
|
||||
}),
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -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' }],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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' }],
|
||||
}),
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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' },
|
||||
|
|
|
|||
|
|
@ -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' },
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ export async function GET(
|
|||
where: { sprint_id: id },
|
||||
orderBy: [
|
||||
{ story: { sort_order: 'asc' } },
|
||||
{ priority: 'asc' },
|
||||
{ sort_order: 'asc' },
|
||||
],
|
||||
take: limit,
|
||||
|
|
|
|||
|
|
@ -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 } },
|
||||
|
|
|
|||
|
|
@ -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' },
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue