Files
leetcode/apps/api/migrations/0002_ladder_3_7.sql
T

32 lines
1.6 KiB
SQL
Raw Normal View History

-- 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';