fix: include overdue tasks in today summary
This commit is contained in:
@@ -377,10 +377,17 @@ async function loadTodayTaskSummary() {
|
||||
const data = await api(`/tasks?${params}`)
|
||||
return Number(data.total ?? data.items?.length ?? 0)
|
||||
}
|
||||
const [open, completed] = await Promise.all([summaryTotal(false), summaryTotal(true)])
|
||||
const overdueTotal = async () => {
|
||||
const params = new URLSearchParams({ page: '1', page_size: '1' })
|
||||
params.set('due_to', isoAtLocalDayOffset(0))
|
||||
params.set('completed', 'false')
|
||||
const data = await api(`/tasks?${params}`)
|
||||
return Number(data.total ?? data.items?.length ?? 0)
|
||||
}
|
||||
const [open, completed, overdue] = await Promise.all([summaryTotal(false), summaryTotal(true), overdueTotal()])
|
||||
if (token !== todaySummaryLoadToken || activeView.value !== 'today') return
|
||||
todayTaskCompleted.value = completed
|
||||
todayTaskTotal.value = open + completed
|
||||
todayTaskTotal.value = overdue + open + completed
|
||||
} catch { /* 概览统计失败不阻断今天页 */ }
|
||||
}
|
||||
async function loadOverdueTasks() {
|
||||
|
||||
@@ -164,7 +164,9 @@ describe('task and habit row decoration', () => {
|
||||
expect(app).toContain('async function loadTodayTaskSummary()')
|
||||
expect(app).toContain('const token = ++todaySummaryLoadToken')
|
||||
expect(app).toContain("params.set('completed', String(completed))")
|
||||
expect(app).toContain('await Promise.all([summaryTotal(false), summaryTotal(true)])')
|
||||
expect(app).toContain('const overdueTotal = async () => {')
|
||||
expect(app).toContain('await Promise.all([summaryTotal(false), summaryTotal(true), overdueTotal()])')
|
||||
expect(app).toContain('todayTaskTotal.value = overdue + open + completed')
|
||||
expect(app).toContain("if (activeView.value === 'today') void loadTodayTaskSummary()")
|
||||
expect(app).toContain('aria-controls="today-tasks"')
|
||||
expect(app).toContain('aria-controls="today-habits"')
|
||||
|
||||
Reference in New Issue
Block a user