Skip to content

Commit

Permalink
review logic tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
szdytom committed Jul 2, 2024
1 parent 3cd9d94 commit 90db1fd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class RatingStore {
async getItem(wordlist) {
let step = await this.currentStep();
let review = [], learn = [], fallback = [];
let low_gap = Infinity, low_gap_item = null;
for (let word of wordlist) {
let item = await this.db.get('ratings', word);
if (item.learnt) {
Expand All @@ -107,6 +108,11 @@ export class RatingStore {
} else {
fallback.push(item);
}

if (gap < low_gap) {
low_gap = gap;
low_gap_item = item;
}
} else {
learn.push(item);
}
Expand All @@ -119,6 +125,7 @@ export class RatingStore {
},
next: getRandomElement(review)
?? getRandomElement(learn)
?? low_gap_item
?? getRandomElement(fallback),
};
}
Expand Down

0 comments on commit 90db1fd

Please sign in to comment.