From 418bf7a07345dab881aac98200d4cfbd3e8e2d55 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 21 Feb 2026 22:06:36 -0600 Subject: [PATCH] Add task sorting by updatedAt (descending) in all views - BacklogView: Sort current sprint tasks, backlog, and other sprint tasks by last updated - SprintBoard: Sort sprint tasks by updatedAt descending - Ensures latest updated tasks appear at top of each section --- scripts/gantt-task-crud.sh | 10 ++++++---- src/components/BacklogView.tsx | 11 +++++++---- src/components/SprintBoard.tsx | 6 ++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/gantt-task-crud.sh b/scripts/gantt-task-crud.sh index 4065e80..81c1f20 100755 --- a/scripts/gantt-task-crud.sh +++ b/scripts/gantt-task-crud.sh @@ -25,17 +25,19 @@ function create_task() { local title="$1" local status="${2:-open}" local priority="${3:-medium}" - local project_id="${4:-1}" + local project_id="${4:-a1b2c3d4-0001-0000-0000-000000000001}" local assignee_id="${5:-9c29cc99-81a1-4e75-8dff-cd7cc5ceb5aa}" - + local task_type="${6:-task}" + local uuid=$(uuidgen | tr '[:upper:]' '[:lower:]') local now=$(date -u +"%Y-%m-%dT%H:%M:%SZ") - + curl -s -X POST "$SUPABASE_URL/rest/v1/tasks" \ "${HEADERS[@]}" \ -d "{ \"id\": \"$uuid\", \"title\": \"$title\", + \"type\": \"$task_type\", \"status\": \"$status\", \"priority\": \"$priority\", \"project_id\": \"$project_id\", @@ -46,7 +48,7 @@ function create_task() { \"tags\": [], \"attachments\": [] }" | jq '.' - + echo "Created task: $uuid" } diff --git a/src/components/BacklogView.tsx b/src/components/BacklogView.tsx index 6aa5fd7..36734ac 100644 --- a/src/components/BacklogView.tsx +++ b/src/components/BacklogView.tsx @@ -318,12 +318,15 @@ export function BacklogView({ searchQuery = "" }: BacklogViewProps) { // Get other sprints (not current) const otherSprints = sprints.filter((s) => s.id !== currentSprint?.id) - // Get tasks by section + // Sort tasks by updatedAt (descending) - latest first + const sortByUpdated = (a: Task, b: Task) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime() + + // Get tasks by section (sorted by last updated) const currentSprintTasks = currentSprint - ? tasks.filter((t) => t.sprintId === currentSprint.id && matchesSearch(t)) + ? tasks.filter((t) => t.sprintId === currentSprint.id && matchesSearch(t)).sort(sortByUpdated) : [] - const backlogTasks = tasks.filter((t) => !t.sprintId && matchesSearch(t)) + const backlogTasks = tasks.filter((t) => !t.sprintId && matchesSearch(t)).sort(sortByUpdated) // Get active task for drag overlay const activeTask = activeId ? tasks.find((t) => t.id === activeId) : null @@ -414,7 +417,7 @@ export function BacklogView({ searchQuery = "" }: BacklogViewProps) { {otherSprints .sort((a, b) => new Date(a.startDate).getTime() - new Date(b.startDate).getTime()) .map((sprint) => { - const sprintTasks = tasks.filter((t) => t.sprintId === sprint.id && matchesSearch(t)) + const sprintTasks = tasks.filter((t) => t.sprintId === sprint.id && matchesSearch(t)).sort(sortByUpdated) console.log(`Sprint ${sprint.name}: ${sprintTasks.length} tasks`, sprintTasks.map(t => t.title)) return ( diff --git a/src/components/SprintBoard.tsx b/src/components/SprintBoard.tsx index f2ff412..3f7d599 100644 --- a/src/components/SprintBoard.tsx +++ b/src/components/SprintBoard.tsx @@ -189,8 +189,10 @@ export function SprintBoard() { // Get current sprint const currentSprint = sprints.find((s) => s.id === selectedSprintId) - // Get tasks for current sprint - const sprintTasks = tasks.filter((t) => t.sprintId === selectedSprintId) + // Get tasks for current sprint, sorted by updatedAt descending (latest first) + const sprintTasks = tasks + .filter((t) => t.sprintId === selectedSprintId) + .sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()) // Group tasks by status const tasksByStatus = statusColumns.reduce((acc, status) => {