Skip to content

Commit

Permalink
remove require elapsed_days
Browse files Browse the repository at this point in the history
  • Loading branch information
ishiko732 committed Sep 26, 2024
1 parent 1ad0c06 commit 2c5f80d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/fsrs/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export interface FSRSReview {
}

export type FSRSHistory = Partial<
Exclude<ReviewLog, 'rating' | 'review' | 'due'>
Exclude<ReviewLog, 'rating' | 'review' | 'due' | 'elapsed_days'>
> &
(
| {
Expand All @@ -104,6 +104,5 @@ export type FSRSHistory = Partial<
due: DateInput
state: State
review: DateInput
elapsed_days: number
}
)
13 changes: 8 additions & 5 deletions src/fsrs/reschedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +43,7 @@ export class Reschedule {
due: <Date>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: <Date>reviewed,
Expand All @@ -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>state,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2c5f80d

Please sign in to comment.