Skip to content

Commit

Permalink
noteStats
Browse files Browse the repository at this point in the history
add: ReviewedCounts

fix null listener

update StatsChart
  • Loading branch information
Newdea committed Sep 10, 2023
1 parent 8b28e04 commit dbc792c
Show file tree
Hide file tree
Showing 21 changed files with 461 additions and 79 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ This is a modified version of [obsidian-spaced-repetition](https://github.com/st
- setting where to save schedule info by Data Location
- save on note file, just as used do.
- save on seperate tracked_files.json.
- it still have problems about saving cards shedule info, because when we change note content, the lineNumber and texthash will changes. I add a eventListener, but note work well in some cases. Is there any good idea?
- setting convert tracked note to decks
- switch Algorithm(only work on saving on seperate tracked_files.json.): Default, anki, [Fsrs](https://github.com/open-spaced-repetition/fsrs.js)
- file menu to tracknote/untracknote
- show floatbar for reviewing response when reviewing note by click statusbar or review command or sidebar, and can set whether showing the interval or not;
- Reviewing a Notes directly [#635];
- when using fsrs, output `ob-revlog.csv`, to optimize the algorithm parameters using [optimizer](https://github.com/open-spaced-repetition/fsrs-optimizer) for better review;
- Statistics: add note view statistics,and today review statistics.

## Maintainers Wanted

Expand Down
7 changes: 4 additions & 3 deletions docs/README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
4. 在有多个标签时,可不用选标签,直接打开笔记;
5. 算法可以切换:默认的 Anki 优化算法、Anki 算法、[Fsrs 算法](https://github.com/open-spaced-repetition/fsrs.js)
6. 使用 Fsrs 算法时,可根据标签输出重复日志文件 `ob_revlog.csv`,以使用[optimizer](https://github.com/open-spaced-repetition/fsrs-optimizer) 优化算法参数,达到更好的复习效果;
7. 其他待发现的小改动;
7. 数据表中新增笔记复习情况、当天复习情况;
8. 其他待发现的小改动;

**注意**
没有使用过 obsidian-spaced-repetition 插件的可以直接用,正在使用 obsidian-spaced-repetition 插件的话,建议试用前先备份 :yum:
Expand Down Expand Up @@ -41,8 +42,8 @@ github: https://github.com/open-spaced-repetition/obsidian-spaced-repetition-rec

或:

1.[最新发布](https://github.com/open-spaced-repetition/obsidian-spaced-repetition-recall/releases/)中下载 main.js, manifest.json, styles.css;
2.`Vault-name/.obsidian/plugins` 中新建个文件夹`obsidian-spaced-repetition-recall`, 把刚下的文件放入新建的文件夹中
1.[最新发布](https://github.com/open-spaced-repetition/obsidian-spaced-repetition-recall/releases/)中下载压缩包(已包括 main.js, manifest.json, styles.css
2.`Vault-name/.obsidian/plugins` 中,把刚下的文件解压(应是`obsidian-spaced-repetition-recall`文件夹)放入`plugins`文件夹下,
3. 重启Obsidan 开启插件,就可以使用了。

## Thanks
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [1.10.1.11]
- 修复: 多设备同步及保存 tracked_files.json 问题;
- 修复: 多标签选择问题 #15
- 新增: 数据表中可查看笔记复习情况、当天复习情况;


## [1.10.1.10]

- fix #12, #14, 复习后数据没有同步更新的问题.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-spaced-repetition-recall",
"name": "Spaced Repetition Recall",
"version": "1.10.1.10",
"version": "1.10.1.11",
"minAppVersion": "0.15.4",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"author": "Newdea",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-spaced-repetition",
"version": "1.10.1.10",
"version": "1.10.1.11",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"main": "main.js",
"scripts": {
Expand Down
52 changes: 51 additions & 1 deletion src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from "./constants";

const ROOT_DATA_PATH = "./tracked_files.json";
const PLUGIN_DATA_PATH = "./.obsidian/plugins/obsidian-spaced-repetition-recall/tracked_files.json";
// const PLUGIN_DATA_PATH = "./.obsidian/plugins/obsidian-spaced-repetition-recall/tracked_files.json";

/**
* SrsData.
Expand All @@ -45,6 +45,15 @@ interface SrsData {
cardRepeatQueue: number[];
toDayAllQueue: Record<number, string>;
toDayLatterQueue: Record<number, string>;

/**
* @type {ReviewedCounts}
*/
reviewedCounts: ReviewedCounts;
/**
* @type {ReviewedCounts}
*/
reviewedCardCounts: ReviewedCounts;
/**
* @type {RepetitionItem[]}
*/
Expand Down Expand Up @@ -72,6 +81,8 @@ export enum RPITEMTYPE {
CARD = "card",
}

export type ReviewedCounts = Record<string, { new: number; due: number }>;

/**
* RepetitionItem.
*/
Expand Down Expand Up @@ -177,6 +188,8 @@ const DEFAULT_SRS_DATA: SrsData = {
cardRepeatQueue: [],
toDayAllQueue: {},
toDayLatterQueue: {},
reviewedCounts: {},
reviewedCardCounts: {},
items: [],
trackedFiles: [],
lastQueue: 0,
Expand Down Expand Up @@ -668,6 +681,13 @@ export class DataStore {
return null;
}

getReviewedCounts() {
return this.data.reviewedCounts;
}
getReviewedCardCounts(): ReviewedCounts {
return this.data.reviewedCardCounts;
}

/**
* reviewId.
* update data according to response opt
Expand Down Expand Up @@ -1200,6 +1220,36 @@ export class DataStore {
}
}

updateReviewedCounts(id: number, type: RPITEMTYPE = RPITEMTYPE.NOTE) {
let rc =this.data.reviewedCounts;
if(type === RPITEMTYPE.NOTE){
rc = this.data.reviewedCounts;
}else{
rc = this.data.reviewedCardCounts;
}
// const date = new Date().toLocaleDateString();
const date = window.moment(new Date()).format("YYYY-MM-DD");
if (!(date in rc)) {
rc[date] = { due: 0, new: 0 };
}
if (this.isDue(id)) {
const item = this.getItembyID(id);
if (this.plugin.data.settings.algorithm === algorithmNames.Fsrs) {
const data: FsrsData = item.data as FsrsData;
if (data.scheduled_days >= 1) {
rc[date].due++;
}
} else {
const data: AnkiData = item.data as AnkiData;
if (data.lastInterval >= 1) {
rc[date].due++;
}
}
} else {
rc[date].new++;
}
}

/**
* renameTrackedFile.
*
Expand Down
5 changes: 3 additions & 2 deletions src/flashcard-modal-algo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import { escapeRegexString, cyrb53 } from "src/utils";
import { t } from "src/lang/helpers";
import { DataLocation, algorithmNames } from "./settings";
import { RepetitionItem } from "./data";
import { RPITEMTYPE, RepetitionItem } from "./data";

export enum FlashcardModalMode {
DecksList,
Expand Down Expand Up @@ -310,7 +310,7 @@ export class FlashcardModal extends Modal {
setIcon(this.openNoteFileButton, "file-edit");
this.openNoteFileButton.setAttribute("aria-label", t("OPEN_NOTE"));
this.openNoteFileButton.addEventListener("click", async () => {
const activeLeaf: WorkspaceLeaf = this.plugin.app.workspace.getLeaf("tab");
const activeLeaf: WorkspaceLeaf = this.plugin.app.workspace.getLeaf();
await activeLeaf.openFile(this.currentCard.note);
if (activeLeaf.view instanceof MarkdownView) {
const activeView = activeLeaf.view;
Expand Down Expand Up @@ -620,6 +620,7 @@ export class FlashcardModal extends Modal {
]);
}
const id = cardinfo.itemIds[this.currentCard.siblingIdx];
store.updateReviewedCounts(id, RPITEMTYPE.CARD);
store.reviewId(id, opt);
store.save();
}
Expand Down
5 changes: 5 additions & 0 deletions src/lang/locale/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,9 @@ export default {
CARD_TYPE_YOUNG: "صغيرة",
CARD_TYPE_MATURE: "ناضجة",
CARD_TYPES_SUMMARY: " ${totalCardsCount} :إجمالي عدد البطاقات",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,9 @@ export default {
CARD_TYPE_YOUNG: "Mladá",
CARD_TYPE_MATURE: "Dospělá",
CARD_TYPES_SUMMARY: "Kartiček celkem: ${totalCardsCount}",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ export default {
CARD_TYPE_YOUNG: "Jung",
CARD_TYPE_MATURE: "Ausgereift",
CARD_TYPES_SUMMARY: "Insgesamt ${totalCardsCount} Karten",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,9 @@ export default {
CARD_TYPE_YOUNG: "Young",
CARD_TYPE_MATURE: "Mature",
CARD_TYPES_SUMMARY: "Total cards: ${totalCardsCount}",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,9 @@ export default {
CARD_TYPE_YOUNG: "Joven",
CARD_TYPE_MATURE: "Madura",
CARD_TYPES_SUMMARY: "Tarjetas Totales: ${totalCardsCount}",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,9 @@ export default {
CARD_TYPE_YOUNG: "復習(初期)",
CARD_TYPE_MATURE: "復習(後期)",
CARD_TYPES_SUMMARY: "カードの合計: ${totalCardsCount}枚",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,9 @@ export default {
CARD_TYPE_YOUNG: "Young",
CARD_TYPE_MATURE: "Mature",
CARD_TYPES_SUMMARY: "전체 카드 수: ${totalCardsCount}",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,9 @@ export default {
CARD_TYPE_YOUNG: "Jovem",
CARD_TYPE_MATURE: "Amadurecido",
CARD_TYPES_SUMMARY: "Total de cartas: ${totalCardsCount}",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ export default {
CARD_TYPE_YOUNG: "Молодых",
CARD_TYPE_MATURE: "Взрослых",
CARD_TYPES_SUMMARY: "Всего карточек: ${totalCardsCount}",
REVIEWED_TODAY: "Reviewed today",
REVIEWED_TODAY_DESC: "counts of cards/notes you have reviewed today",
NEW_LEARNED: "New Learned",
DUE_REVIEWED: "due Reviewed",
REVIEWED_TODAY_SUMMARY: "Total Reviewed today: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,9 @@ export default {
CARD_TYPE_YOUNG: "较新",
CARD_TYPE_MATURE: "熟悉",
CARD_TYPES_SUMMARY: "总卡片数: ${totalCardsCount}",
REVIEWED_TODAY: "今天复习情况",
REVIEWED_TODAY_DESC: "今天已经复习的卡片/笔记的数量",
NEW_LEARNED: "新学",
DUE_REVIEWED: "复习",
REVIEWED_TODAY_SUMMARY: "总复习数: ${totalreviewedCount}",
};
5 changes: 5 additions & 0 deletions src/lang/locale/zh-tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,9 @@ export default {
CARD_TYPE_YOUNG: "較新",
CARD_TYPE_MATURE: "熟悉",
CARD_TYPES_SUMMARY: "總卡片數: ${totalCardsCount}",
REVIEWED_TODAY: "今天復習情況",
REVIEWED_TODAY_DESC: "今天已經復習的卡片/筆記的數量",
NEW_LEARNED: "新學",
DUE_REVIEWED: "復習",
REVIEWED_TODAY_SUMMARY: "總復習數: ${totalreviewedCount}",
};
Loading

0 comments on commit dbc792c

Please sign in to comment.