Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add note stats #1140

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ coverage:
round: down
precision: 2
status:
project: true
project: false
patch:
default:
target: 100
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"dependencies": {
"chart.js": "^4.4.4",
"clozecraft": "^0.4.0",
"gridjs": "^6.2.0",
"minimatch": "^10.0.1",
"pagerank.js": "^1.0.2",
"short-uuid": "^5.2.0"
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions src/algorithms/base/isrs-algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ReviewResponse } from "src/algorithms/base/repetition-item";
import { OsrNoteGraph } from "src/algorithms/osr/osr-note-graph";
import { DueDateHistogram } from "src/due-date-histogram";
import { Note } from "src/note";
import { INoteEaseList } from "src/note-ease-list";

export enum Algorithm {
SM_2_OSR = "SM-2-OSR",
Expand All @@ -22,6 +23,7 @@ export interface ISrsAlgorithm {
response: ReviewResponse,
dueDateNoteHistogram: DueDateHistogram,
): RepItemScheduleInfo;
noteStats(): INoteEaseList;

cardGetResetSchedule(): RepItemScheduleInfo;
cardGetNewSchedule(
Expand Down
4 changes: 4 additions & 0 deletions src/algorithms/osr/srs-algorithm-osr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,8 @@ export class SrsAlgorithmOsr implements ISrsAlgorithm {
const delayBeforeReview = 0;
return new RepItemScheduleInfoOsr(dueDate, interval, ease, delayBeforeReview);
}

noteStats() {
return this.noteEaseList;
}
}
6 changes: 0 additions & 6 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { CardDueDateHistogram, NoteDueDateHistogram } from "src/due-date-histogr
import { ISRFile, SrTFile } from "src/file";
import { FlashcardReviewMode } from "src/flashcard-review-sequencer";
import { Note } from "src/note";
import { NoteEaseList } from "src/note-ease-list";
import { NoteFileLoader } from "src/note-file-loader";
import { NoteReviewQueue } from "src/note-review-queue";
import { QuestionPostponementList } from "src/question-postponement-list";
Expand All @@ -32,7 +31,6 @@ export class OsrCore {
private dataChangedHandler: () => void;
protected osrNoteGraph: OsrNoteGraph;
private osrNoteLinkInfoFinder: IOsrVaultNoteLinkInfoFinder;
private _easeByPath: NoteEaseList;
private _questionPostponementList: QuestionPostponementList;
private _noteReviewQueue: NoteReviewQueue;

Expand Down Expand Up @@ -67,10 +65,6 @@ export class OsrCore {
return this._dueDateNoteHistogram;
}

get easeByPath(): NoteEaseList {
return this._easeByPath;
}

get cardStats(): Stats {
return this._cardStats;
}
Expand Down
2 changes: 0 additions & 2 deletions src/data-stores/notes/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import { RepItemScheduleInfoOsr } from "src/algorithms/osr/rep-item-schedule-inf
import { LEGACY_SCHEDULING_EXTRACTOR, MULTI_SCHEDULING_EXTRACTOR } from "src/constants";
import { IDataStore } from "src/data-stores/base/data-store";
import { RepItemStorageInfo } from "src/data-stores/base/rep-item-storage-info";
import { NoteEaseList } from "src/note-ease-list";
import { Question } from "src/question";
import { SRSettings } from "src/settings";
import { DateUtil, formatDateYYYYMMDD, globalDateProvider } from "src/utils/dates";

export class StoreInNotes implements IDataStore {
private settings: SRSettings;
app: App;
easeByPath: NoteEaseList;

constructor(settings: SRSettings) {
this.settings = settings;
Expand Down
47 changes: 46 additions & 1 deletion src/gui/statistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ import {
Title,
Tooltip,
} from "chart.js";
import { Grid } from "gridjs";
import path from "path";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import h from "vhtml";

import { SrsAlgorithm } from "src/algorithms/base/srs-algorithm";
import { textInterval } from "src/algorithms/osr/note-scheduling";
import { OsrCore } from "src/core";
import { CardListType } from "src/deck";
import { t } from "src/lang/helpers";
import { Stats } from "src/stats";
import { getKeysPreserveType, getTypedObjectEntries } from "src/utils/types";
import { getKeysPreserveType, getTypedObjectEntries, mapRecord } from "src/utils/types";

Chart.register(
BarElement,
Expand Down Expand Up @@ -99,6 +102,10 @@ export class StatisticsView {
<canvas id="cardTypesChart"></canvas>
<br />
<span id="cardTypesChartSummary"></span>
<br />
<br />
<h1>Notes</h1>
<div id="noteStats"></div>
</div>
);

Expand Down Expand Up @@ -188,6 +195,44 @@ export class StatisticsView {
[cardStats.newCount, cardStats.youngCount, cardStats.matureCount],
t("CARD_TYPES_SUMMARY", { totalCardsCount }),
);

const noteEases = mapRecord(
SrsAlgorithm.getInstance().noteStats().dict,
(key: string, value: number): [string, number] => [
path.parse(key).name,
Math.round(value),
],
);

const grid = new Grid({
columns: [
{
name: t("NOTE"),
},
{
name: t("EASE"),
sort: true,
width: "200px",
},
],
search: true,
autoWidth: false,
data: Object.entries(noteEases).sort((a, b) => b[1] - a[1]),
pagination: {
limit: 10,
summary: false,
},
language: {
search: {
placeholder: t("SEARCH"),
},
pagination: {
previous: t("PREVIOUS"),
next: t("NEXT"),
},
},
});
grid.render(document.getElementById("noteStats"));
}

destroy(): void {
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 @@ -129,6 +129,7 @@ export default {
MULTILINE_REVERSED_CARDS_SEPARATOR: "فاصل من أجل البطاقات العكسية المتعددة",
MULTILINE_CARDS_END_MARKER: "الأحرف التي تدل على نهاية الكلوزات وبطاقات التعلم المتعددة الأسطر",
NOTES: "ملاحظات",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "تمكين جزء مراجعة الملاحظات عند بدء التشغيل",
TAGS_TO_REVIEW: "وسوم للمراجعة",
TAGS_TO_REVIEW_DESC: "#أدخل الوسوم مفصولة بمسافات أو خطوط جديدة ، أي : مراجعة# وسم2# وسم3",
Expand Down Expand Up @@ -207,10 +208,14 @@ export default {
INTERVALS_SUMMARY: "${longest} : أطول فاصل زمني ,${avg} :متوسط الفاصل الزمني",
EASES: "السهولة",
EASES_SUMMARY: "${avgEase} :متوسط السهولة",
EASE: "Ease",
CARD_TYPES: "أنواع البطاقات",
CARD_TYPES_DESC: "وهذا يشمل البطاقات المخفية كذلك ، إن وجدت",
CARD_TYPE_NEW: "جديدة",
CARD_TYPE_YOUNG: "صغيرة",
CARD_TYPE_MATURE: "ناضجة",
CARD_TYPES_SUMMARY: " ${totalCardsCount} :إجمالي عدد البطاقات",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
5 changes: 5 additions & 0 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default {
MULTILINE_REVERSED_CARDS_SEPARATOR: "Oddělovač pro víceřádkove otočené kartičky",
MULTILINE_CARDS_END_MARKER: "Znaky označující konec clozes a víceřádkových flash karet",
NOTES: "Poznámky",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "Enable note review pane on startup",
TAGS_TO_REVIEW: "Tag pro revizi",
TAGS_TO_REVIEW_DESC:
Expand Down Expand Up @@ -212,10 +213,14 @@ export default {
INTERVALS_SUMMARY: "Průměrný interval: ${avg}, Nejdelší interval: ${longest}",
EASES: "Složitost",
EASES_SUMMARY: "Průměrná složitost: ${avgEase}",
EASE: "Ease",
CARD_TYPES: "Typy kartiček",
CARD_TYPES_DESC: "Obsahuje i odložené kartičky (pokud existují)",
CARD_TYPE_NEW: "Nová",
CARD_TYPE_YOUNG: "Mladá",
CARD_TYPE_MATURE: "Dospělá",
CARD_TYPES_SUMMARY: "Kartiček celkem: ${totalCardsCount}",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
5 changes: 5 additions & 0 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export default {
MULTILINE_CARDS_END_MARKER:
"Zeichen, die das Ende von Lückentexten und mehrzeiligen Flashcards kennzeichnen",
NOTES: "Notizen",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "Öffne Überprüfungswarteschlage beim start",
TAGS_TO_REVIEW: "Zu wiederholende Tags",
TAGS_TO_REVIEW_DESC:
Expand Down Expand Up @@ -232,10 +233,14 @@ export default {
INTERVALS_SUMMARY: "Durchschnittliches Intervall: ${avg}, Längstes Intervall: ${longest}",
EASES: "Schwierigkeit",
EASES_SUMMARY: "Durchschnittliche Schwierigkeit: ${avgEase}",
EASE: "Ease",
CARD_TYPES: "Kategorisierung",
CARD_TYPES_DESC: "Verlegte Karten eingeschlossen",
CARD_TYPE_NEW: "Neu",
CARD_TYPE_YOUNG: "Jung",
CARD_TYPE_MATURE: "Ausgereift",
CARD_TYPES_SUMMARY: "Insgesamt ${totalCardsCount} Karten",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
5 changes: 5 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default {
MULTILINE_REVERSED_CARDS_SEPARATOR: "Separator for multiline reversed flashcards",
MULTILINE_CARDS_END_MARKER: "Characters denoting the end of clozes and multiline flashcards",
NOTES: "Notes",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "Enable note review pane on startup",
TAGS_TO_REVIEW: "Tags to review",
TAGS_TO_REVIEW_DESC: "Enter tags separated by spaces or newlines i.e. #review #tag2 #tag3.",
Expand Down Expand Up @@ -212,10 +213,14 @@ export default {
INTERVALS_SUMMARY: "Average interval: ${avg}, Longest interval: ${longest}",
EASES: "Eases",
EASES_SUMMARY: "Average ease: ${avgEase}",
EASE: "Ease",
CARD_TYPES: "Card Types",
CARD_TYPES_DESC: "This includes buried cards as well, if any",
CARD_TYPE_NEW: "New",
CARD_TYPE_YOUNG: "Young",
CARD_TYPE_MATURE: "Mature",
CARD_TYPES_SUMMARY: "Total cards: ${totalCardsCount}",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
5 changes: 5 additions & 0 deletions src/lang/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default {
MULTILINE_CARDS_END_MARKER:
"Caracteres que denotan el fin de los clozes y tarjetas didácticas de varias líneas",
NOTES: "Notes",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "Activar panel de revisión de notas al arrancar",
TAGS_TO_REVIEW: "Etiquetas a revisar",
TAGS_TO_REVIEW_DESC:
Expand Down Expand Up @@ -219,10 +220,14 @@ export default {
INTERVALS_SUMMARY: "Intervalo de carga: ${avg}, Intervalo mayor: ${longest}",
EASES: "Facilidad",
EASES_SUMMARY: "Carga de Facilidad: ${avgEase}",
EASE: "Ease",
CARD_TYPES: "Tipos de tarjetas",
CARD_TYPES_DESC: "Esto incluye también a las tarjetas enterradas, si las hay",
CARD_TYPE_NEW: "Nueva",
CARD_TYPE_YOUNG: "Joven",
CARD_TYPE_MATURE: "Madura",
CARD_TYPES_SUMMARY: "Tarjetas Totales: ${totalCardsCount}",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
5 changes: 5 additions & 0 deletions src/lang/locale/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default {
MULTILINE_CARDS_END_MARKER:
"Caractères de fin de textes à trous ou de flashcards en plusieurs lignes",
NOTES: "Notes",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "Montrer le module d'apprentissage des notes au démarrage",
TAGS_TO_REVIEW: "Tags à apprendre",
TAGS_TO_REVIEW_DESC:
Expand Down Expand Up @@ -220,10 +221,14 @@ export default {
INTERVALS_SUMMARY: "Intervalle moyen : ${avg}. Intervalle maximum: ${longest}",
EASES: "Facilité",
EASES_SUMMARY: "Facilité moyenne : ${avgEase}",
EASE: "Ease",
CARD_TYPES: "Types de cartes",
CARD_TYPES_DESC: "Ceci inclut les cartes enterrées, s'il y en a",
CARD_TYPE_NEW: "Nouvelles",
CARD_TYPE_YOUNG: "En cours d'apprentissage",
CARD_TYPE_MATURE: "Matures",
CARD_TYPES_SUMMARY: "Total de cartes : ${totalCardsCount}",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
5 changes: 5 additions & 0 deletions src/lang/locale/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default {
MULTILINE_CARDS_END_MARKER:
"Caratteri che denotano la fine di carte con spazi da riempiere e carte multilinea",
NOTES: "Note",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "Abilita il pannello di revisione note all'avvio",
TAGS_TO_REVIEW: "Etichette da rivedere",
TAGS_TO_REVIEW_DESC:
Expand Down Expand Up @@ -223,10 +224,14 @@ export default {
INTERVALS_SUMMARY: "Intervallo medio: ${avg}, Intervallo massimo: ${longest}",
EASES: "Difficoltà",
EASES_SUMMARY: "Difficoltà media: ${avgEase}",
EASE: "Ease",
CARD_TYPES: "Tipi di schede",
CARD_TYPES_DESC: "Include eventuali schede sepolte",
CARD_TYPE_NEW: "Nuove",
CARD_TYPE_YOUNG: "Giovani",
CARD_TYPE_MATURE: "Mature",
CARD_TYPES_SUMMARY: "Schede tottali: ${totalCardsCount}",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
5 changes: 5 additions & 0 deletions src/lang/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default {
MULTILINE_REVERSED_CARDS_SEPARATOR: "複数行の表裏反転フラッシュカードに使用するセパレーター",
MULTILINE_CARDS_END_MARKER: "クローズと複数行フラッシュカードの終わりを示す文字",
NOTES: "ノート",
NOTE: "Note",
REVIEW_PANE_ON_STARTUP: "Enable note review pane on startup",
TAGS_TO_REVIEW: "レビューに使用するタグ",
TAGS_TO_REVIEW_DESC:
Expand Down Expand Up @@ -216,10 +217,14 @@ export default {
INTERVALS_SUMMARY: "間隔の平均値: ${avg}, 最長の間隔: ${longest}",
EASES: "易しさ",
EASES_SUMMARY: "易しさの平均値: ${avgEase}",
EASE: "Ease",
CARD_TYPES: "カードタイプ",
CARD_TYPES_DESC: "延期のカードがある場合にはこれに含まれます",
CARD_TYPE_NEW: "新規",
CARD_TYPE_YOUNG: "復習(初期)",
CARD_TYPE_MATURE: "復習(後期)",
CARD_TYPES_SUMMARY: "カードの合計: ${totalCardsCount}枚",
SEARCH: "Search",
PREVIOUS: "Previous",
NEXT: "Next",
};
Loading