-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmodels.go
92 lines (79 loc) · 1.52 KB
/
models.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package fsrs
import (
"time"
)
type Card struct {
Due time.Time `json:"Due"`
Stability float64 `json:"Stability"`
Difficulty float64 `json:"Difficulty"`
ElapsedDays uint64 `json:"ElapsedDays"`
ScheduledDays uint64 `json:"ScheduledDays"`
Reps uint64 `json:"Reps"`
Lapses uint64 `json:"Lapses"`
State State `json:"State"`
LastReview time.Time `json:"LastReview"`
}
func NewCard() Card {
return Card{
Due: time.Time{},
Stability: 0,
Difficulty: 0,
ElapsedDays: 0,
ScheduledDays: 0,
Reps: 0,
Lapses: 0,
State: New,
LastReview: time.Time{},
}
}
type ReviewLog struct {
Rating Rating `json:"Rating"`
ScheduledDays uint64 `json:"ScheduledDays"`
ElapsedDays uint64 `json:"ElapsedDays"`
Review time.Time `json:"Review"`
State State `json:"State"`
}
type schedulingCards struct {
Again Card
Hard Card
Good Card
Easy Card
}
func (s *schedulingCards) init(card Card) {
s.Again = card
s.Hard = card
s.Good = card
s.Easy = card
}
type SchedulingInfo struct {
Card Card
ReviewLog ReviewLog
}
type RecordLog map[Rating]SchedulingInfo
type Rating int8
const (
Again Rating = iota + 1
Hard
Good
Easy
)
func (s Rating) String() string {
switch s {
case Again:
return "Again"
case Hard:
return "Hard"
case Good:
return "Good"
case Easy:
return "Easy"
}
return "unknown"
}
type State int8
const (
New State = iota
Learning
Review
Relearning
)