feat(api): add recent solves, yearly stats, and miss count to API

This commit is contained in:
Prad Nukala committed 2026-09-29 17:28:49 -04:00
1 parent f2a2d2d7de
commit f4fc0fd0e7
3 files changed
+87 -5

No files matched your search

+9
View File
@@ -310,6 +310,15 @@ export async function lookupProblems(
export const DUE_WHERE = `stage != 'retired' AND next_review IS NOT NULL AND next_review <= ?1
AND (defer_until IS NULL OR defer_until <= ?1)`;
/**
* What an open miss means, in one place: a problem `p` whose most recent
* attempt (highest id) failed and that has not retired. The sweep day works
* these and the stats' "attempting" count is how many there are, so the two
* cannot disagree. Expects `problems p` joined to `attempts a` on lc_number.
*/
export const MISS_WHERE = `a.id = (SELECT MAX(id) FROM attempts WHERE lc_number = p.lc_number)
AND a.result = 'fail' AND p.stage != 'retired'`;
/** Reviews due on/before `date`, oldest first — the overflow carry order. */
export async function dueReviews(db: D1Database, date: string): Promise<ProblemRow[]> {
const { results } = await db