|
@@ -228,7 +228,7 @@ func ReviewFlashcard(deckID, cardID string, rating riff.Rating, reviewedCardIDs
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- dueCards := getDueFlashcards(deckID, reviewedCardIDs)
|
|
|
+ dueCards, _ := getDueFlashcards(deckID, reviewedCardIDs)
|
|
|
if 1 > len(dueCards) {
|
|
|
// 该卡包中没有待复习的卡片了,说明最后一张卡片已经复习完了,清空撤销缓存和跳过缓存
|
|
|
reviewCardCache = map[string]riff.Card{}
|
|
@@ -277,7 +277,7 @@ func newFlashcard(card riff.Card, blockID, deckID string, now time.Time) *Flashc
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Flashcard, err error) {
|
|
|
+func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Flashcard, unreviewedCount int, err error) {
|
|
|
deckLock.Lock()
|
|
|
defer deckLock.Unlock()
|
|
|
|
|
@@ -320,7 +320,7 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Fl
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- cards := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
|
|
|
+ cards, unreviewdCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
|
|
|
now := time.Now()
|
|
|
for _, card := range cards {
|
|
|
blockID := card.BlockID()
|
|
@@ -329,10 +329,11 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Fl
|
|
|
if 1 > len(ret) {
|
|
|
ret = []*Flashcard{}
|
|
|
}
|
|
|
+ unreviewedCount = unreviewdCnt
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flashcard, err error) {
|
|
|
+func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flashcard, unreviewedCount int, err error) {
|
|
|
deckLock.Lock()
|
|
|
defer deckLock.Unlock()
|
|
|
|
|
@@ -347,7 +348,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
|
|
|
}
|
|
|
|
|
|
treeBlockIDs := getTreeSubTreeChildBlocks(rootID)
|
|
|
- cards := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
|
|
|
+ cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
|
|
|
now := time.Now()
|
|
|
for _, card := range cards {
|
|
|
blockID := card.BlockID()
|
|
@@ -356,6 +357,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
|
|
|
if 1 > len(ret) {
|
|
|
ret = []*Flashcard{}
|
|
|
}
|
|
|
+ unreviewedCount = unreviewedCnt
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -395,7 +397,7 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs []string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard, err error) {
|
|
|
+func GetDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard, unreviewedCount int, err error) {
|
|
|
deckLock.Lock()
|
|
|
defer deckLock.Unlock()
|
|
|
|
|
@@ -405,22 +407,22 @@ func GetDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard
|
|
|
}
|
|
|
|
|
|
if "" == deckID {
|
|
|
- ret = getAllDueFlashcards(reviewedCardIDs)
|
|
|
+ ret, unreviewedCount = getAllDueFlashcards(reviewedCardIDs)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- ret = getDueFlashcards(deckID, reviewedCardIDs)
|
|
|
+ ret, unreviewedCount = getDueFlashcards(deckID, reviewedCardIDs)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard) {
|
|
|
+func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard, unreviewedCount int) {
|
|
|
deck := Decks[deckID]
|
|
|
if nil == deck {
|
|
|
logging.LogWarnf("deck not found [%s]", deckID)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- cards := getDeckDueCards(deck, reviewedCardIDs, nil)
|
|
|
+ cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, nil)
|
|
|
now := time.Now()
|
|
|
for _, card := range cards {
|
|
|
blockID := card.BlockID()
|
|
@@ -434,13 +436,14 @@ func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard
|
|
|
if 1 > len(ret) {
|
|
|
ret = []*Flashcard{}
|
|
|
}
|
|
|
+ unreviewedCount = unreviewedCnt
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard) {
|
|
|
+func getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard, unreviewedCount int) {
|
|
|
now := time.Now()
|
|
|
for _, deck := range Decks {
|
|
|
- cards := getDeckDueCards(deck, reviewedCardIDs, nil)
|
|
|
+ cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, nil)
|
|
|
for _, card := range cards {
|
|
|
blockID := card.BlockID()
|
|
|
if nil == treenode.GetBlockTree(blockID) {
|
|
@@ -448,6 +451,7 @@ func getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard) {
|
|
|
}
|
|
|
|
|
|
ret = append(ret, newFlashcard(card, blockID, deck.ID, now))
|
|
|
+ unreviewedCount += unreviewedCnt
|
|
|
}
|
|
|
}
|
|
|
if 1 > len(ret) {
|
|
@@ -817,18 +821,31 @@ func getDeckIDs() (deckIDs []string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string) (ret []riff.Card) {
|
|
|
+func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string) (ret []riff.Card, unreviewedCount int) {
|
|
|
ret = []riff.Card{}
|
|
|
dues := deck.Dues()
|
|
|
|
|
|
- newCount := 0
|
|
|
- reviewCount := 0
|
|
|
+ var tmp []riff.Card
|
|
|
for _, c := range dues {
|
|
|
- if nil != skipCardCache[c.ID()] {
|
|
|
+ if 0 < len(blockIDs) && !gulu.Str.Contains(c.BlockID(), blockIDs) {
|
|
|
continue
|
|
|
}
|
|
|
+ tmp = append(tmp, c)
|
|
|
|
|
|
- if 0 < len(blockIDs) && !gulu.Str.Contains(c.BlockID(), blockIDs) {
|
|
|
+ if 0 < len(reviewedCardIDs) {
|
|
|
+ if !gulu.Str.Contains(c.ID(), reviewedCardIDs) {
|
|
|
+ unreviewedCount++
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ unreviewedCount++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dues = tmp
|
|
|
+
|
|
|
+ newCount := 0
|
|
|
+ reviewCount := 0
|
|
|
+ for _, c := range dues {
|
|
|
+ if nil != skipCardCache[c.ID()] {
|
|
|
continue
|
|
|
}
|
|
|
|