From 28ba578fc7b6986096b78cf53eae09d8ef52239b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 24 Jan 2025 19:06:33 +1100 Subject: [PATCH] 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. --- rslib/src/storage/revlog/fix_props.sql | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/rslib/src/storage/revlog/fix_props.sql b/rslib/src/storage/revlog/fix_props.sql index 28bffb431..7806abb75 100644 --- a/rslib/src/storage/revlog/fix_props.sql +++ b/rslib/src/storage/revlog/fix_props.sql @@ -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) \ No newline at end of file + 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 + ) \ No newline at end of file