Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 支持间隔复习 https://github.com/siyuan-note/siyuan/issues/6710

Liang Dingc5b1279c82c0
diff --git a/kernel/api/riff.go b/kernel/api/riff.go
index f471d61330..af81ab68f2 100644
--- a/kernel/api/riff.go
+++ b/kernel/api/riff.go
@@ -56,7 +56,6 @@ func getRiffDueCards(c *gin.Context) {
}
deckID := arg["deckID"].(string)
-
cards, err := model.GetDueFlashcards(deckID)
if nil != err {
ret.Code = -1
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go
index d0e1b3b2dc..aac181e8d1 100644
--- a/kernel/model/flashcard.go
+++ b/kernel/model/flashcard.go
@@ -45,12 +45,11 @@ func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err err
return
}
-type Flashcard struct {
- ID string
- BlockID string
-}
+func GetDueFlashcards(deckID string) (ret []string, err error) {
+ if "" == deckID {
+ return getAllDueFlashcards()
+ }
-func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
deckLock.Lock()
deck := Decks[deckID]
deckLock.Unlock()
@@ -62,10 +61,29 @@ func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
if nil != getErr {
continue
}
- ret = append(ret, &Flashcard{
- ID: card.ID(),
- BlockID: blockID,
- })
+ ret = append(ret, blockID)
+ }
+ return
+}
+
+func getAllDueFlashcards() (ret []string, err error) {
+ blockIDs := map[string]bool{}
+ for _, deck := range Decks {
+ cards := deck.Dues()
+ for _, card := range cards {
+ blockID := card.BlockID()
+ _, getErr := GetBlock(blockID)
+ if nil != getErr {
+ continue
+ }
+
+ if blockIDs[blockID] {
+ continue
+ }
+
+ ret = append(ret, blockID)
+ blockIDs[blockID] = true
+ }
}
return
}