From 6cb4155e8e87ce37dbf46492b4c162bf3d5e9c04 Mon Sep 17 00:00:00 2001 From: Abdo Date: Mon, 13 Nov 2023 03:23:46 +0300 Subject: [PATCH] Show due date of buried/suspended cards in card info (#2820) * Show due date of buried/suspended cards in card info * Simplify match and handle relearning cards * Omit ctype checks * Test due, not card.due (dae) --- rslib/src/stats/card.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/rslib/src/stats/card.rs b/rslib/src/stats/card.rs index d90b0208f..c052cd10b 100644 --- a/rslib/src/stats/card.rs +++ b/rslib/src/stats/card.rs @@ -70,27 +70,28 @@ impl Collection { } else { card.due }; - Ok(match card.queue { - CardQueue::New => (None, Some(due)), - CardQueue::Learn => ( - Some(TimestampSecs::now().0), - card.original_position.map(|u| u as i32), - ), - CardQueue::Review | CardQueue::DayLearn => ( + Ok(match card.ctype { + CardType::New => { + if matches!(card.queue, CardQueue::Review | CardQueue::DayLearn) { + // new preview card not answered yet + (None, card.original_position.map(|u| u as i32)) + } else { + (None, Some(due)) + } + } + CardType::Review | CardType::Learn | CardType::Relearn => ( { - if card.ctype == CardType::New { - // new preview card not answered yet - None - } else { + if due <= 1_000_000_000 { let days_remaining = due - (self.timing_today()?.days_elapsed as i32); let mut due = TimestampSecs::now(); due.0 += (days_remaining as i64) * 86_400; Some(due.0) + } else { + Some(TimestampSecs::now().0) } }, card.original_position.map(|u| u as i32), ), - _ => (None, None), }) } }