From a4d5777e1d25ca366d54f2de8a00f1933acb28d1 Mon Sep 17 00:00:00 2001 From: twotalesanimation <80506065+twotalesanimation@users.noreply.github.com> Date: Sun, 18 Oct 2026 05:18:18 +0200 Subject: [PATCH] fix(shot-status): sort shots by shot code, not shotNumber Imports and the external API assign shotNumber as max+10 (or 0), which needn't match the number in the shot code, so new shots could sink to the bottom of the list. Sort by episode then natural shot-code order. Co-Authored-By: Claude Opus 5.5 --- app/(dashboard)/shot-status/page.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/(dashboard)/shot-status/page.tsx b/app/(dashboard)/shot-status/page.tsx index 570973e..b351a64 100644 --- a/app/(dashboard)/shot-status/page.tsx +++ b/app/(dashboard)/shot-status/page.tsx @@ -30,14 +30,11 @@ async function getAssignableArtists() { }); } +const shotCodeCollator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }); + async function getShotsForProject(projectId: string) { const shots = await db.shot.findMany({ where: { projectId }, - orderBy: [ - { episode: { sort: "asc", nulls: "last" } }, - { scene: "asc" }, - { shotNumber: "asc" }, - ], select: { id: true, shotCode: true, @@ -90,6 +87,16 @@ async function getShotsForProject(projectId: string) { }, }); + // Sorted by shot code rather than scene + shotNumber: imports and the + // external API assign shotNumber as "max + 10" (or 0), which needn't match + // the number in the code, so new shots could sink to the bottom. + shots.sort( + (a, b) => + (a.episode === null ? 1 : 0) - (b.episode === null ? 1 : 0) || + shotCodeCollator.compare(a.episode ?? "", b.episode ?? "") || + shotCodeCollator.compare(a.shotCode, b.shotCode) + ); + return shots.map(({ exports, ...shot }) => ({ ...shot, delivery: summariseShotDelivery({