Home: the Tasks card lists what is overdue or due this week from every list, with a tick
build-container / build (push) Successful in 10m51s
build-container / build (push) Successful in 10m51s
This commit is contained in:
1 parent
2b79160f95
commit
d598501393
3 files changed
+18
-5
No files matched your search
@@ -152,6 +152,12 @@ async function handle(req, res) {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(from) || !/^\d{4}-\d{2}-\d{2}$/.test(to)) throw new Error('Bad date range');
|
||||
return json(res, 200, (await allTasks()).filter(x => !x.done && !x.parent && x.due && x.due >= from && x.due <= to).slice(0, 500));
|
||||
}
|
||||
if (p === '/api/tasks/upcoming' && req.method === 'GET') { // for the Home card: what is overdue, due today or due in the next week, from every list
|
||||
const today = q.get('today') || new Date().toISOString().slice(0, 10); if (!/^\d{4}-\d{2}-\d{2}$/.test(today)) throw new Error('Bad date');
|
||||
const end = new Date(today + 'T00:00:00Z'); end.setUTCDate(end.getUTCDate() + 7); const last = end.toISOString().slice(0, 10);
|
||||
const rows = (await allTasks()).filter(x => !x.done && !x.parent && x.due && x.due <= last).sort((a, b) => a.due.localeCompare(b.due) || a.title.localeCompare(b.title));
|
||||
return json(res, 200, { total: rows.length, tasks: rows.slice(0, 8) });
|
||||
}
|
||||
if (p === '/api/tasks/summary' && req.method === 'GET') { // for the Home card: open tasks that are overdue or due today
|
||||
const today = q.get('today') || new Date().toISOString().slice(0, 10), out = { overdue: 0, today: 0, open: 0 };
|
||||
const count = list => list.forEach(t => { if (t.done) return; out.open++; if (t.due && t.due < today) out.overdue++; else if (t.due === today) out.today++; });
|
||||
|
||||
Reference in new issue
Block a user