An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: The status of flashcards after re-reviewing the previous one is incorrect https://github.com/siyuan-note/siyuan/issues/9988
Danieladc42291c6be
diff --git a/kernel/go.mod b/kernel/go.modindex b0c56dc97a..5eb924eece 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -56,7 +56,7 @@ require (github.com/siyuan-note/filelock v0.0.0-20231211015131-3b3dfabdce9cgithub.com/siyuan-note/httpclient v0.0.0-20231219001541-d75e4dce39fagithub.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0- github.com/siyuan-note/riff v0.0.0-20231222032533-1f1b309dbc08+ github.com/siyuan-note/riff v0.0.0-20231226152006-8833f8b9a6c1github.com/spf13/cast v1.6.0github.com/steambap/captcha v1.4.1github.com/studio-b12/gowebdav v0.9.0diff --git a/kernel/go.sum b/kernel/go.sumindex b9c5c0596b..483a8ce756 100644--- a/kernel/go.sum+++ b/kernel/go.sum@@ -366,8 +366,8 @@ github.com/siyuan-note/httpclient v0.0.0-20231219001541-d75e4dce39fa h1:kfWxJzNPgithub.com/siyuan-note/httpclient v0.0.0-20231219001541-d75e4dce39fa/go.mod h1:ejS8ChupXGP89C8N4nM+xhyxVVf/IfcwOXboql6o3+g=github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0 h1:+XjUr9UMXsczdO2bGA72p/k9wa2ShPb8ybi7CDBJ7HQ=github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=-github.com/siyuan-note/riff v0.0.0-20231222032533-1f1b309dbc08 h1:vPZqpEIT8gqtFM23FHbxhaCeCzccHB/KFR7OEZfAt0U=-github.com/siyuan-note/riff v0.0.0-20231222032533-1f1b309dbc08/go.mod h1:wLzj67jwt8PM+qWPGlC4V7m0fzkUlkwPKf9vLF6ru/k=+github.com/siyuan-note/riff v0.0.0-20231226152006-8833f8b9a6c1 h1:MziLTkbS4qTpeuANYEQQK5yQRSkdRXXNs+JKksbaMQk=+github.com/siyuan-note/riff v0.0.0-20231226152006-8833f8b9a6c1/go.mod h1:wLzj67jwt8PM+qWPGlC4V7m0fzkUlkwPKf9vLF6ru/k=github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY=diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex 437abfcc9f..b7e7ba9fad 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -390,7 +390,7 @@ func ReviewFlashcard(deckID, cardID string, rating riff.Rating, reviewedCardIDsdelete(skipCardCache, cardID)} else {// 首次复习该卡片,将卡片缓存以便后续支持撤销后再次复习- reviewCardCache[cardID] = card+ reviewCardCache[cardID] = card.Clone()}log := deck.Review(cardID, rating)@@ -404,8 +404,8 @@ func ReviewFlashcard(deckID, cardID string, rating riff.Rating, reviewedCardIDsreturn}- dueCards, _, _, _ := getDueFlashcards(deckID, reviewedCardIDs)- if 1 > len(dueCards) {+ _, unreviewedCount, _, _ := getDueFlashcards(deckID, reviewedCardIDs)+ if 1 > unreviewedCount {// 该卡包中没有待复习的卡片了,说明最后一张卡片已经复习完了,清空撤销缓存和跳过缓存reviewCardCache = map[string]riff.Card{}skipCardCache = map[string]riff.Card{}@@ -988,7 +988,7 @@ func getDeckIDs() (deckIDs []string) {return}-func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCardLimit, reviewCardLimit int) (ret []riff.Card, unreviewedCount, unreviewedNewCardCount, unreviewedOldCardCount int) {+func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCardLimit, reviewCardLimit int) (ret []riff.Card, unreviewedCount, unreviewedNewCardCountInRound, unreviewedOldCardCountInRound int) {ret = []riff.Card{}dues := deck.Dues()@@ -1006,7 +1006,8 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCar}dues = tmp- if 1 > len(reviewedCardIDs) {+ reviewedCardCount := len(reviewedCardIDs)+ if 1 > reviewedCardCount {// 未传入已复习的卡片 ID,说明是开始新的复习,需要清空缓存reviewCardCache = map[string]riff.Card{}skipCardCache = map[string]riff.Card{}@@ -1014,43 +1015,59 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCarnewCount := 0reviewCount := 0- for _, c := range dues {- if nil != skipCardCache[c.ID()] {- continue- }-- if riff.New == c.GetState() {- if newCount >= newCardLimit {- continue- }-+ for _, reviewedCard := range reviewCardCache {+ if riff.New == reviewedCard.GetState() {newCount++} else {- if reviewCount >= reviewCardLimit {- continue- }-reviewCount++}+ }++ for _, c := range dues {+ if nil != skipCardCache[c.ID()] {+ continue+ }if 0 < len(reviewedCardIDs) {if !gulu.Str.Contains(c.ID(), reviewedCardIDs) {unreviewedCount++if riff.New == c.GetState() {- unreviewedNewCardCount+++ if newCount < newCardLimit {+ unreviewedNewCardCountInRound+++ }} else {- unreviewedOldCardCount+++ if reviewCount < reviewCardLimit {+ unreviewedOldCardCountInRound+++ }}}} else {unreviewedCount++if riff.New == c.GetState() {- unreviewedNewCardCount+++ if newCount < newCardLimit {+ unreviewedNewCardCountInRound+++ }} else {- unreviewedOldCardCount+++ if reviewCount < reviewCardLimit {+ unreviewedOldCardCountInRound+++ }}}+ if riff.New == c.GetState() {+ if newCount >= newCardLimit {+ continue+ }++ newCount+++ } else {+ if reviewCount >= reviewCardLimit {+ continue+ }++ reviewCount+++ }+ret = append(ret, c)}return