An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Show count in spaced repetition tree filter floating window https://github.com/siyuan-note/siyuan/issues/8202
Liang Ding2678dfc8272a
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex d0806accac..7e8022c740 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -76,27 +76,20 @@ func countTreeFlashcard(rootID string, deck *riff.Deck, deckBlockIDs []string) (}func countBoxFlashcard(boxID string, deck *riff.Deck, deckBlockIDs []string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {- entries, err := os.ReadDir(filepath.Join(util.DataDir, boxID))- if nil != err {- logging.LogErrorf("read dir failed: %s", err)+ blockIDs := getBoxBlocks(boxID)+ for _, blockID := range deckBlockIDs {+ if gulu.Str.Contains(blockID, blockIDs) {+ flashcardCount+++ }+ }+ if 1 > flashcardCount {return}- for _, entry := range entries {- if entry.IsDir() {- continue- }-- if !strings.HasSuffix(entry.Name(), ".sy") {- continue- }-- rootID := strings.TrimSuffix(entry.Name(), ".sy")- treeNewFlashcardCount, treeDueFlashcardCount, treeFlashcardCount := countTreeFlashcard(rootID, deck, deckBlockIDs)- flashcardCount += treeFlashcardCount- newFlashcardCount += treeNewFlashcardCount- dueFlashcardCount += treeDueFlashcardCount- }+ newFlashCards := deck.GetNewCardsByBlockIDs(blockIDs)+ newFlashcardCount = len(newFlashCards)+ newDueFlashcards := deck.GetDueCardsByBlockIDs(blockIDs)+ dueFlashcardCount = len(newDueFlashcards)return}@@ -421,6 +414,14 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs []string) {return}+func getBoxBlocks(boxID string) (blockIDs []string) {+ bts := treenode.GetBlockTreesByBoxID(boxID)+ for _, bt := range bts {+ blockIDs = append(blockIDs, bt.ID)+ }+ return+}+func GetDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard, unreviewedCount int, err error) {deckLock.Lock()defer deckLock.Unlock()diff --git a/kernel/treenode/blocktree.go b/kernel/treenode/blocktree.goindex 045a7f35ce..01dab254e4 100644--- a/kernel/treenode/blocktree.go+++ b/kernel/treenode/blocktree.go@@ -255,6 +255,21 @@ func RemoveBlockTreesByPathPrefix(pathPrefix string) {}}+func GetBlockTreesByBoxID(boxID string) (ret []*BlockTree) {+ blockTrees.Range(func(key, value interface{}) bool {+ slice := value.(*btSlice)+ slice.m.Lock()+ for _, b := range slice.data {+ if b.BoxID == boxID {+ ret = append(ret, b)+ }+ }+ slice.m.Unlock()+ return true+ })+ return+}+func RemoveBlockTreesByBoxID(boxID string) (ids []string) {blockTrees.Range(func(key, value interface{}) bool {slice := value.(*btSlice)