Skip to content

Commit cc2f663

Browse files
authored
Merge: Integrate with the official R calculation
2 parents 8a123a5 + fe7c1f3 commit cc2f663

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"jszip": "^3.10.1",
3535
"style-loader": "^3.3.3",
3636
"sweetalert2": "^11.15.10",
37-
"ts-fsrs": "^4.6.0",
37+
"ts-fsrs": "^4.7.0",
3838
"webpack": "^5.89.0",
3939
"webpack-cli": "^5.1.4"
4040
},

src/popup/util/utils.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import localStorageDelegate from "../delegate/localStorageDelegate";
22
import cloudStorageDelegate from "../delegate/cloudStorageDelegate";
33
import { store } from "../store";
44
import { COMPILE_ERROR_AND_TLE_CLASSNAME, COMPILE_ERROR_AND_TLE_CLASSNAME_CN, COMPILE_ERROR_AND_TLE_CLASSNAME_NEW, PAGE_SIZE, SUBMIT_BUTTON_ATTRIBUTE_NAME, SUBMIT_BUTTON_ATTRIBUTE_VALUE, SUCCESS_CLASSNAME, SUCCESS_CLASSNAME_CN, SUCCESS_CLASSNAME_NEW, WRONG_ANSWER_CLASSNAME, WRONG_ANSWER_CLASSNAME_CN, WRONG_ANSWER_CLASSNAME_NEW, forggettingCurve } from "./constants";
5+
import { forgetting_curve, dateDiffInDays } from "ts-fsrs"
56

67
export const needReview = (problem) => {
78
if (problem.proficiency >= forggettingCurve.length) {
@@ -169,12 +170,6 @@ export const getCurrentRetrievability = (problem) => {
169170
return 1;
170171
}
171172

172-
const now = Date.now();
173-
const elapsedDays = (now - problem.fsrsState.lastReview) / (24 * 60 * 60 * 1000);
174-
return calculateRetrievability(problem.fsrsState.stability, elapsedDays);
175-
};
176-
177-
// 计算可检索性的辅助函数
178-
const calculateRetrievability = (stability, elapsedDays) => {
179-
return Math.exp(Math.log(0.9) * elapsedDays / stability);
173+
const elapsedDays = dateDiffInDays(new Date(problem.fsrsState.lastReview), new Date());
174+
return forgetting_curve(elapsedDays, problem.fsrsState.stability);
180175
};

0 commit comments

Comments
 (0)