mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
fecd965dfb
commit
c5b1279c82
2 changed files with 27 additions and 10 deletions
|
|
@ -56,7 +56,6 @@ func getRiffDueCards(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
deckID := arg["deckID"].(string)
|
deckID := arg["deckID"].(string)
|
||||||
|
|
||||||
cards, err := model.GetDueFlashcards(deckID)
|
cards, err := model.GetDueFlashcards(deckID)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,11 @@ func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
type Flashcard struct {
|
func GetDueFlashcards(deckID string) (ret []string, err error) {
|
||||||
ID string
|
if "" == deckID {
|
||||||
BlockID string
|
return getAllDueFlashcards()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
|
|
||||||
deckLock.Lock()
|
deckLock.Lock()
|
||||||
deck := Decks[deckID]
|
deck := Decks[deckID]
|
||||||
deckLock.Unlock()
|
deckLock.Unlock()
|
||||||
|
|
@ -62,10 +61,29 @@ func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
|
||||||
if nil != getErr {
|
if nil != getErr {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ret = append(ret, &Flashcard{
|
ret = append(ret, blockID)
|
||||||
ID: card.ID(),
|
}
|
||||||
BlockID: 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
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue