From d784575c87544d108ff7b8718cfecbec9a792ba7 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Mon, 31 Aug 2026 10:41:33 -0400 Subject: [PATCH] feat(migrations): rebuild ladder stages and shift Sunday dates --- apps/api/migrations/0002_ladder_3_7.sql | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 apps/api/migrations/0002_ladder_3_7.sql diff --git a/apps/api/migrations/0002_ladder_3_7.sql b/apps/api/migrations/0002_ladder_3_7.sql new file mode 100644 index 0000000..2d7a808 --- /dev/null +++ b/apps/api/migrations/0002_ladder_3_7.sql @@ -0,0 +1,31 @@ +-- Ladder rebuild: +2/+5/+10 → +3/+7, and no scheduled date on a Sunday. +-- +-- The old three rungs scattered reviews across every weekday, so roughly one +-- review in seven came due on the rest day: the digest hid it (Sunday builds +-- an empty body) and Monday inherited the pile. The campaign's windows are 3 +-- and 7 days — the same numbers as the work/3 and work/7 buckets and the +-- Spaced Repetition issue windows — and srs.ts now mints every date through +-- workingDay(), which never returns a Sunday. +-- +-- Stage remap keeps earned progress: a problem at +5 has passed one review, so +-- it owes the 7-day one; a problem at +10 has passed two and is done. Existing +-- next_review dates keep their day (recomputing them would move work the +-- reader has already been told about) — only Sunday landings shift, forward to +-- Monday, because a review may come later than its interval but never sooner. +-- +-- problems.stage is now: new | +3 | +7 | retired + +UPDATE problems SET stage = '+3' WHERE stage = '+2'; +UPDATE problems SET stage = '+7' WHERE stage = '+5'; +UPDATE problems SET stage = 'retired', next_review = NULL WHERE stage = '+10'; + +UPDATE problems + SET next_review = date(next_review, '+1 day') + WHERE next_review IS NOT NULL AND strftime('%w', next_review) = '0'; + +-- defer_until is the deferred Hards' release date; catalog.ts spreads them two +-- per working day, so the same rule applies. next_review tracks it for a row +-- that is still `new`, and the shift above kept the two in step. +UPDATE problems + SET defer_until = date(defer_until, '+1 day') + WHERE defer_until IS NOT NULL AND strftime('%w', defer_until) = '0';