From 78a6813b9b1dbb21fb6c4dc759cfaab75795415b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 16 May 2020 15:58:25 +1000 Subject: [PATCH] when merging day# in deck, make sure to reset older values --- rslib/src/decks/schema11.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/rslib/src/decks/schema11.rs b/rslib/src/decks/schema11.rs index 98691831b..c7616d35d 100644 --- a/rslib/src/decks/schema11.rs +++ b/rslib/src/decks/schema11.rs @@ -258,18 +258,27 @@ impl From<&DeckCommonSchema11> for DeckCommon { } else { serde_json::to_vec(&common.other).unwrap_or_default() }; + // since we're combining the day values into a single value, + // any items from an earlier day need to be reset + let mut today = common.today.clone(); + // time is always updated, so will always be the latest + let max_day = today.time.day; + if today.lrn.day != max_day { + today.lrn.amount = 0; + } + if today.rev.day != max_day { + today.rev.amount = 0; + } + if today.new.day != max_day { + today.new.amount = 0; + } DeckCommon { study_collapsed: common.study_collapsed, browser_collapsed: common.browser_collapsed, - last_day_studied: common - .today - .new - .day - .max(common.today.lrn.day) - .max(common.today.rev.day) as u32, - new_studied: common.today.new.amount, - review_studied: common.today.rev.amount, - learning_studied: common.today.lrn.amount, + last_day_studied: max_day as u32, + new_studied: today.new.amount, + review_studied: today.rev.amount, + learning_studied: today.lrn.amount, secs_studied: common.today.time.amount, other, }