forked from st3v3nmw/obsidian-spaced-repetition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.ts
42 lines (34 loc) · 1.1 KB
/
stats.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { ValueCountDict } from "./util/NumberCountDict";
export class Stats {
eases: ValueCountDict = new ValueCountDict();
intervals: ValueCountDict = new ValueCountDict();
delayedDays: ValueCountDict = new ValueCountDict();
newCount: number = 0;
youngCount: number = 0;
matureCount: number = 0;
get totalCount(): number {
return this.youngCount + this.matureCount;
}
incrementNew() {
this.newCount++;
}
update(delayedDays: number, interval: number, ease: number) {
this.intervals.incrementCount(interval);
this.eases.incrementCount(ease);
this.delayedDays.incrementCount(delayedDays);
if (interval >= 32) {
this.matureCount++;
} else {
this.youngCount++;
}
}
getMaxInterval(): number {
return this.intervals.getMaxValue();
}
getAverageInterval(): number {
return this.intervals.getTotalOfValueMultiplyCount() / this.totalCount;
}
getAverageEases(): number {
return this.eases.getTotalOfValueMultiplyCount() / this.totalCount;
}
}