Fix invalid reschedule revlog entries

https://forums.ankiweb.net/t/statistics-messed-up-after-fsrs-reschedule/54622

Caused by syncing the revlogs in a normal sync to a client that doesn't
understand them yet - they end up using the default for RevlogReviewKind
instead, which is 0.
This commit is contained in:
Damien Elmes 2025-01-24 19:06:33 +11:00
parent 5f68c5208e
commit 28ba578fc7

View file

@ -1,7 +1,23 @@
UPDATE revlog
SET ivl = min(max(round(ivl), -2147483648), 2147483647),
lastIvl = min(max(round(lastIvl), -2147483648), 2147483647),
time = min(max(round(time), 0), 2147483647)
time = min(max(round(time), 0), 2147483647),
type = (
CASE
WHEN type = 0
AND time = 0
AND ease = 0 THEN 5
ELSE type
END
)
WHERE ivl != min(max(round(ivl), -2147483648), 2147483647)
OR lastIvl != min(max(round(lastIvl), -2147483648), 2147483647)
OR time != min(max(round(time), 0), 2147483647)
OR type != (
CASE
WHEN type = 0
AND time = 0
AND ease = 0 THEN 5
ELSE type
END
)