🎨 Apply result optimized by FSRS optimizer https://github.com/siyuan-note/siyuan/issues/9309

This commit is contained in:
Daniel 2023-09-28 22:22:17 +08:00
parent b2a27bb54c
commit 6354d04e4b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
10 changed files with 104 additions and 10 deletions

View file

@ -16,6 +16,12 @@
package conf
import (
"bytes"
"fmt"
"github.com/open-spaced-repetition/go-fsrs"
)
type Flashcard struct {
NewCardLimit int `json:"newCardLimit"` // 新卡上限 https://github.com/siyuan-note/siyuan/issues/7695
ReviewCardLimit int `json:"reviewCardLimit"` // 复习卡上限 https://github.com/siyuan-note/siyuan/issues/7703
@ -23,15 +29,32 @@ type Flashcard struct {
List bool `json:"list"` // 是否启用列表块制卡 https://github.com/siyuan-note/siyuan/issues/7701
SuperBlock bool `json:"superBlock"` // 是否启用超级块制卡 https://github.com/siyuan-note/siyuan/issues/7702
Deck bool `json:"deck"` // 是否启用卡包制卡 https://github.com/siyuan-note/siyuan/issues/7724
// Apply result optimized by FSRS optimizer https://github.com/siyuan-note/siyuan/issues/9309
RequestRetention float64 `json:"requestRetention"`
MaximumInterval float64 `json:"maximumInterval"`
Weights string `json:"weights"`
}
func NewFlashcard() *Flashcard {
param := fsrs.DefaultParam()
weightsBuilder := bytes.Buffer{}
for i, w := range param.W {
weightsBuilder.WriteString(fmt.Sprintf("%.2f", w))
if i < len(param.W)-1 {
weightsBuilder.WriteString(", ")
}
}
return &Flashcard{
NewCardLimit: 20,
ReviewCardLimit: 200,
Mark: true,
List: true,
SuperBlock: true,
Deck: false,
NewCardLimit: 20,
ReviewCardLimit: 200,
Mark: true,
List: true,
SuperBlock: true,
Deck: false,
RequestRetention: param.RequestRetention,
MaximumInterval: param.MaximumInterval,
Weights: weightsBuilder.String(),
}
}

View file

@ -350,6 +350,15 @@ func InitConf() {
if 0 > Conf.Flashcard.ReviewCardLimit {
Conf.Flashcard.ReviewCardLimit = 200
}
if 0 >= Conf.Flashcard.RequestRetention || 1 <= Conf.Flashcard.RequestRetention {
Conf.Flashcard.RequestRetention = conf.NewFlashcard().RequestRetention
}
if 0 >= Conf.Flashcard.MaximumInterval || 36500 <= Conf.Flashcard.MaximumInterval {
Conf.Flashcard.MaximumInterval = conf.NewFlashcard().MaximumInterval
}
if "" == Conf.Flashcard.Weights || 17 != len(strings.Split(Conf.Flashcard.Weights, ",")) {
Conf.Flashcard.Weights = conf.NewFlashcard().Weights
}
if nil == Conf.AI {
Conf.AI = conf.NewAI()