Add dueDate field and sort tasks by deadline then project
Parse due_date/dueDate/deadline from task frontmatter. Sort API output with due-date tasks first (soonest at top), then group remaining tasks by project name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
af5fb23b28
commit
e39e6fc398
|
|
@ -511,8 +511,17 @@ export class BacklogAggregator {
|
||||||
tasks = tasks.filter((t) => (t.priority ?? "").toLowerCase() === priority.toLowerCase());
|
tasks = tasks.filter((t) => (t.priority ?? "").toLowerCase() === priority.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by project then by task ID
|
// Sort: due-date tasks first (soonest/overdue at top), then by project, then by task ID
|
||||||
|
const now = new Date().toISOString().slice(0, 10);
|
||||||
tasks = tasks.sort((a, b) => {
|
tasks = tasks.sort((a, b) => {
|
||||||
|
const aDue = a.dueDate || "";
|
||||||
|
const bDue = b.dueDate || "";
|
||||||
|
// Tasks with due dates come before tasks without
|
||||||
|
if (aDue && !bDue) return -1;
|
||||||
|
if (!aDue && bDue) return 1;
|
||||||
|
// Both have due dates: sort soonest first
|
||||||
|
if (aDue && bDue) return aDue.localeCompare(bDue);
|
||||||
|
// Neither has due date: group by project, then by task ID
|
||||||
const projectCompare = a.projectName.localeCompare(b.projectName);
|
const projectCompare = a.projectName.localeCompare(b.projectName);
|
||||||
if (projectCompare !== 0) return projectCompare;
|
if (projectCompare !== 0) return projectCompare;
|
||||||
return sortByTaskId([a, b])[0] === a ? -1 : 1;
|
return sortByTaskId([a, b])[0] === a ? -1 : 1;
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,13 @@ export function parseTask(content: string): Task {
|
||||||
: frontmatter.estimatedHours !== undefined
|
: frontmatter.estimatedHours !== undefined
|
||||||
? Number(frontmatter.estimatedHours)
|
? Number(frontmatter.estimatedHours)
|
||||||
: undefined,
|
: undefined,
|
||||||
|
dueDate: frontmatter.due_date
|
||||||
|
? normalizeDate(frontmatter.due_date)
|
||||||
|
: frontmatter.dueDate
|
||||||
|
? normalizeDate(frontmatter.dueDate)
|
||||||
|
: frontmatter.deadline
|
||||||
|
? normalizeDate(frontmatter.deadline)
|
||||||
|
: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ export interface Task {
|
||||||
doToday?: boolean;
|
doToday?: boolean;
|
||||||
/** Estimated hours to complete the task (for time tracking and invoicing) */
|
/** Estimated hours to complete the task (for time tracking and invoicing) */
|
||||||
estimatedHours?: number;
|
estimatedHours?: number;
|
||||||
|
/** Due date / deadline for the task (YYYY-MM-DD or YYYY-MM-DD HH:mm) */
|
||||||
|
dueDate?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue