From 03f3a005f4821720938ae600ddcc74f8321468fa Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Sat, 27 Sep 2025 13:46:50 +0800 Subject: [PATCH] Fix/first and latest review dates should only consider entries with a rating. (#4360) * Fix/first and latest review dates should only only consider entries with a rating. * Update rslib/src/stats/card.rs Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com> --------- Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com> --- rslib/src/stats/card.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rslib/src/stats/card.rs b/rslib/src/stats/card.rs index 008977fe9..a76edffa2 100644 --- a/rslib/src/stats/card.rs +++ b/rslib/src/stats/card.rs @@ -76,8 +76,15 @@ impl Collection { note_id: card.note_id.into(), deck: deck.human_name(), added: card.id.as_secs().0, - first_review: revlog.first().map(|entry| entry.id.as_secs().0), - latest_review: revlog.last().map(|entry| entry.id.as_secs().0), + first_review: revlog + .iter() + .find(|entry| entry.has_rating()) + .map(|entry| entry.id.as_secs().0), + // last_review_time is not used to ensure cram revlogs are included. + latest_review: revlog + .iter() + .rfind(|entry| entry.has_rating()) + .map(|entry| entry.id.as_secs().0), due_date: self.due_date(&card)?, due_position: self.position(&card), interval: card.interval,