🎨 Add internal kernel API /api/riff/batchSetRiffCardsDueTime https://github.com/siyuan-note/siyuan/issues/10423

This commit is contained in:
Daniel 2024-02-24 22:04:36 +08:00
parent 3ec2ff243f
commit 285eb12b48
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 78 additions and 12 deletions

View file

@ -38,6 +38,46 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
type SetFlashcardDueTime struct {
ID string `json:"id"` // 卡片 ID
Due string `json:"due"` // 下次复习时间,格式为 YYYYMMDDHHmmss
}
func SetFlashcardsDueTime(cardDues []*SetFlashcardDueTime) (err error) {
// Add internal kernel API `/api/riff/batchSetRiffCardsDueTime` https://github.com/siyuan-note/siyuan/issues/10423
deckLock.Lock()
defer deckLock.Unlock()
waitForSyncingStorages()
deck := Decks[builtinDeckID]
if nil == deck {
return
}
for _, cardDue := range cardDues {
card := deck.GetCard(cardDue.ID)
if nil == card {
continue
}
due, parseErr := time.Parse("20060102150405", cardDue.Due)
if nil != parseErr {
logging.LogErrorf("parse due time [%s] failed: %s", cardDue.Due, err)
err = parseErr
return
}
card.SetDue(due)
}
if err = deck.Save(); nil != err {
logging.LogErrorf("save deck [%s] failed: %s", builtinDeckID, err)
}
return
}
func ResetFlashcards(typ, id, deckID string, blockIDs []string) {
// Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564