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
This commit is contained in:
Max 2026-02-21 22:06:36 -06:00
parent 02d19a1afb
commit 418bf7a073
3 changed files with 17 additions and 10 deletions

View File

@ -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"
}

View File

@ -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 (
<SectionDropZone key={sprint.id} id={`sprint-${sprint.id}`}>

View File

@ -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) => {