oboeru

a collection of simple, scriptable flashcard programs
git clone anongit@rnpnr.xyz:oboeru.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 9f3ef399f0ebfd385243a235b5e6b5677efe2c06
Parent: 02af2bd1fb2aa24ebbcef11a86df6f975f96b352
Author: Randy Palamar
Date:   Sat, 21 Aug 2021 14:25:45 -0600

oboeru: only timestamp review on first review of the session

this mostly reverts the last commit which was based on a misunderstanding
of the problem. the reason we were hitting that branch twice was because
the review timestamp was being updated more than once.

we still add an extra 1s to avoid any rounding error the next time the
card is reviewed

Diffstat:
Moboeru.c | 22+++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/oboeru.c b/oboeru.c @@ -165,30 +165,34 @@ bump_card(Card *card, int8_t status) int64_t diff; time_t t = time(NULL); - if (card->nobump && status != CARD_FAIL) { - card->reviewed = t; + if (card->nobump && status != CARD_FAIL) return 0; - } diff = card->due - card->reviewed; if (diff < 0) fprintf(stderr, "card id: %ld: malformed review time\n", card->id); + /* only hit this on the first time through */ + if (!card->nobump) + card->reviewed = t; + switch (status) { case CARD_PASS: if (diff < MINIMUM_INCREASE) { - /* + extra 90s so we don't hit this branch twice */ - card->due = t + MINIMUM_INCREASE + 90; + /* extra 1s to avoid rounding errors */ + card->due = t + MINIMUM_INCREASE + 1; return 1; - } else { - card->due = t + diff * GROWTH_RATE; - card->reviewed = t; } + card->due = t + diff * GROWTH_RATE; break; case CARD_FAIL: if (diff > LEECH_AGE && !card->nobump) card->leeches++; - card->due = t + diff * SHRINK_RATE; + + if (diff * SHRINK_RATE < MINIMUM_INCREASE) + card->due = t + MINIMUM_INCREASE + 1; + else + card->due = t + diff * SHRINK_RATE; return 1; }