feat(api): add dueToday endpoint, shared DUE_WHERE constant, and commit rung handling

This commit is contained in:
Prad Nukala committed 2026-08-31 10:48:24 -04:00
1 parent 38fbb18f32
commit 5ea123e46d
3 files changed
+124 -33

No files matched your search

+2 -5
View File
@@ -7,6 +7,7 @@
import {
CAMPAIGN_DAYS,
CAMPAIGN_START,
DUE_WHERE,
addDays,
campaignDay,
campaignWeek,
@@ -78,11 +79,7 @@ export async function buildStats(db: D1Database, today: string): Promise<object>
for (let i = 0; i < 14; i++) {
const date = addDays(today, i);
const row = await db
.prepare(
`SELECT COUNT(*) AS n FROM problems
WHERE stage != 'retired' AND next_review IS NOT NULL AND next_review <= ?1
AND (defer_until IS NULL OR defer_until <= ?1)`,
)
.prepare(`SELECT COUNT(*) AS n FROM problems WHERE ${DUE_WHERE}`)
.bind(date)
.first<{ n: number }>();
queue.push({ date, due: row?.n ?? 0 });