diff --git a/src/fsrs/models.ts b/src/fsrs/models.ts index 353213f..0017bb0 100644 --- a/src/fsrs/models.ts +++ b/src/fsrs/models.ts @@ -92,7 +92,7 @@ export interface FSRSReview { } export type FSRSHistory = Partial< - Exclude + Exclude > & ( | { @@ -104,6 +104,5 @@ export type FSRSHistory = Partial< due: DateInput state: State review: DateInput - elapsed_days: number } ) diff --git a/src/fsrs/reschedule.ts b/src/fsrs/reschedule.ts index d125077..bfdb2e2 100644 --- a/src/fsrs/reschedule.ts +++ b/src/fsrs/reschedule.ts @@ -26,7 +26,7 @@ export class Reschedule { card: Card, state: State, reviewed: Date, - elapsed_days?: number, + elapsed_days: number, stability?: number, difficulty?: number, due?: Date @@ -43,7 +43,7 @@ export class Reschedule { due: due ?? reviewed, stability: card.stability, difficulty: card.difficulty, - elapsed_days: elapsed_days || 0, + elapsed_days: elapsed_days, last_elapsed_days: card.elapsed_days, scheduled_days: card.scheduled_days, review: reviewed, @@ -55,8 +55,6 @@ export class Reschedule { throw new Error('reschedule: due is required for manual rating') } const scheduled_days = due.diff(reviewed as Date, 'days') - elapsed_days = - elapsed_days || reviewed.diff(card.last_review as Date, 'days') log = { rating: Rating.Manual, state: state, @@ -90,11 +88,16 @@ export class Reschedule { for (const review of reviews) { let item: RecordLogItem if (review.rating === Rating.Manual) { + // ref: abstract_scheduler.ts#init + let interval = 0 + if (_card.state !== State.New && _card.last_review) { + interval = review.review.diff(_card.last_review as Date, 'days') + } item = this.processManual( _card, review.state, review.review, - review.elapsed_days, + interval, review.stability, review.difficulty, review.due