mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
🎨 Show count in spaced repetition tree filter floating window https://github.com/siyuan-note/siyuan/issues/8202
This commit is contained in:
parent
413d13eb57
commit
48fd525abb
1 changed files with 14 additions and 11 deletions
|
|
@ -58,9 +58,9 @@ func GetFlashcardNotebooks() (ret []*Box) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func countTreeFlashcard(rootID string, deck *riff.Deck, deckBlockIDs []string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
func countTreeFlashcard(rootID string, deck *riff.Deck, deckBlockIDs []string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
||||||
blockIDs := getTreeSubTreeChildBlocks(rootID)
|
blockIDsMap, blockIDs := getTreeSubTreeChildBlocks(rootID)
|
||||||
for _, deckBlockID := range deckBlockIDs {
|
for _, deckBlockID := range deckBlockIDs {
|
||||||
if gulu.Str.Contains(deckBlockID, blockIDs) {
|
if blockIDsMap[deckBlockID] {
|
||||||
flashcardCount++
|
flashcardCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,9 +76,9 @@ func countTreeFlashcard(rootID string, deck *riff.Deck, deckBlockIDs []string) (
|
||||||
}
|
}
|
||||||
|
|
||||||
func countBoxFlashcard(boxID string, deck *riff.Deck, deckBlockIDs []string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
func countBoxFlashcard(boxID string, deck *riff.Deck, deckBlockIDs []string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
||||||
blockIDs := getBoxBlocks(boxID)
|
blockIDsMap, blockIDs := getBoxBlocks(boxID)
|
||||||
for _, deckBlockID := range deckBlockIDs {
|
for _, deckBlockID := range deckBlockIDs {
|
||||||
if gulu.Str.Contains(deckBlockID, blockIDs) {
|
if blockIDsMap[deckBlockID] {
|
||||||
flashcardCount++
|
flashcardCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, page
|
||||||
|
|
||||||
var treeBlockIDs []string
|
var treeBlockIDs []string
|
||||||
for _, rootID := range rootIDs {
|
for _, rootID := range rootIDs {
|
||||||
blockIDs := getTreeSubTreeChildBlocks(rootID)
|
_, blockIDs := getTreeSubTreeChildBlocks(rootID)
|
||||||
treeBlockIDs = append(treeBlockIDs, blockIDs...)
|
treeBlockIDs = append(treeBlockIDs, blockIDs...)
|
||||||
}
|
}
|
||||||
treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)
|
treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)
|
||||||
|
|
@ -155,9 +155,9 @@ func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCou
|
||||||
|
|
||||||
var allBlockIDs []string
|
var allBlockIDs []string
|
||||||
deckBlockIDs := deck.GetBlockIDs()
|
deckBlockIDs := deck.GetBlockIDs()
|
||||||
treeBlockIDs := getTreeSubTreeChildBlocks(rootID)
|
treeBlockIDsMap, _ := getTreeSubTreeChildBlocks(rootID)
|
||||||
for _, blockID := range deckBlockIDs {
|
for _, blockID := range deckBlockIDs {
|
||||||
if gulu.Str.Contains(blockID, treeBlockIDs) {
|
if treeBlockIDsMap[blockID] {
|
||||||
allBlockIDs = append(allBlockIDs, blockID)
|
allBlockIDs = append(allBlockIDs, blockID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +352,7 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Fl
|
||||||
|
|
||||||
var treeBlockIDs []string
|
var treeBlockIDs []string
|
||||||
for _, rootID := range rootIDs {
|
for _, rootID := range rootIDs {
|
||||||
blockIDs := getTreeSubTreeChildBlocks(rootID)
|
_, blockIDs := getTreeSubTreeChildBlocks(rootID)
|
||||||
treeBlockIDs = append(treeBlockIDs, blockIDs...)
|
treeBlockIDs = append(treeBlockIDs, blockIDs...)
|
||||||
}
|
}
|
||||||
treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)
|
treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)
|
||||||
|
|
@ -387,7 +387,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
treeBlockIDs := getTreeSubTreeChildBlocks(rootID)
|
_, treeBlockIDs := getTreeSubTreeChildBlocks(rootID)
|
||||||
cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
|
cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
for _, card := range cards {
|
for _, card := range cards {
|
||||||
|
|
@ -401,7 +401,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs []string) {
|
func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDsMap map[string]bool, treeBlockIDs []string) {
|
||||||
root := treenode.GetBlockTree(rootID)
|
root := treenode.GetBlockTree(rootID)
|
||||||
if nil == root {
|
if nil == root {
|
||||||
return
|
return
|
||||||
|
|
@ -409,14 +409,17 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs []string) {
|
||||||
|
|
||||||
bts := treenode.GetBlockTreesByPathPrefix(strings.TrimSuffix(root.Path, ".sy"))
|
bts := treenode.GetBlockTreesByPathPrefix(strings.TrimSuffix(root.Path, ".sy"))
|
||||||
for _, bt := range bts {
|
for _, bt := range bts {
|
||||||
|
treeBlockIDsMap[bt.ID] = true
|
||||||
treeBlockIDs = append(treeBlockIDs, bt.ID)
|
treeBlockIDs = append(treeBlockIDs, bt.ID)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBoxBlocks(boxID string) (blockIDs []string) {
|
func getBoxBlocks(boxID string) (blockIDsMap map[string]bool, blockIDs []string) {
|
||||||
|
blockIDsMap = map[string]bool{}
|
||||||
bts := treenode.GetBlockTreesByBoxID(boxID)
|
bts := treenode.GetBlockTreesByBoxID(boxID)
|
||||||
for _, bt := range bts {
|
for _, bt := range bts {
|
||||||
|
blockIDsMap[bt.ID] = true
|
||||||
blockIDs = append(blockIDs, bt.ID)
|
blockIDs = append(blockIDs, bt.ID)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue