mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 02:21:38 +08:00
This commit is contained in:
parent
545fc07314
commit
f69487f562
@ -45,7 +45,7 @@ require (
|
|||||||
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e
|
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e
|
||||||
github.com/siyuan-note/httpclient v0.0.0-20221213030227-fa8d21fd9cf8
|
github.com/siyuan-note/httpclient v0.0.0-20221213030227-fa8d21fd9cf8
|
||||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a
|
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a
|
||||||
github.com/siyuan-note/riff v0.0.0-20221223145438-041dea8f7945
|
github.com/siyuan-note/riff v0.0.0-20221228031102-17d458a1217b
|
||||||
github.com/steambap/captcha v1.4.1
|
github.com/steambap/captcha v1.4.1
|
||||||
github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012
|
github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012
|
||||||
github.com/vmihailenco/msgpack/v5 v5.3.5
|
github.com/vmihailenco/msgpack/v5 v5.3.5
|
||||||
@ -134,6 +134,7 @@ require (
|
|||||||
replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5
|
replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5
|
||||||
|
|
||||||
//replace github.com/siyuan-note/dejavu => D:\88250\dejavu
|
//replace github.com/siyuan-note/dejavu => D:\88250\dejavu
|
||||||
|
//replace github.com/siyuan-note/riff => D:\88250\riff
|
||||||
//replace github.com/siyuan-note/httpclient => D:\88250\httpclient
|
//replace github.com/siyuan-note/httpclient => D:\88250\httpclient
|
||||||
//replace github.com/siyuan-note/filelock => D:\88250\filelock
|
//replace github.com/siyuan-note/filelock => D:\88250\filelock
|
||||||
//replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lute
|
//replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lute
|
||||||
|
@ -385,8 +385,8 @@ github.com/siyuan-note/httpclient v0.0.0-20221213030227-fa8d21fd9cf8 h1:cv0U38yu
|
|||||||
github.com/siyuan-note/httpclient v0.0.0-20221213030227-fa8d21fd9cf8/go.mod h1:aLj3LQVz2iuA3AUfkqk1UvPhqafRpthAVtjV1+ZAq+U=
|
github.com/siyuan-note/httpclient v0.0.0-20221213030227-fa8d21fd9cf8/go.mod h1:aLj3LQVz2iuA3AUfkqk1UvPhqafRpthAVtjV1+ZAq+U=
|
||||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a h1:b9VJCE8IccYjsadwNBI11he+Wn25hI9lCma4uYoIYEM=
|
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a h1:b9VJCE8IccYjsadwNBI11he+Wn25hI9lCma4uYoIYEM=
|
||||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a/go.mod h1:t1zRGxK13L/9ZFoGyTD39IbFCbee3CsypDj4b5dt4qM=
|
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a/go.mod h1:t1zRGxK13L/9ZFoGyTD39IbFCbee3CsypDj4b5dt4qM=
|
||||||
github.com/siyuan-note/riff v0.0.0-20221223145438-041dea8f7945 h1:ED7QFLeOu5/PpXK1v0ax82MJrhpgPrxkq6UEhIEOnFA=
|
github.com/siyuan-note/riff v0.0.0-20221228031102-17d458a1217b h1:JDpKOdiyocNsgKFfrF3mB7UoBJz4qcHBUKBig78kVjc=
|
||||||
github.com/siyuan-note/riff v0.0.0-20221223145438-041dea8f7945/go.mod h1:WnNt0JPjfXp2fjAgbF9rS5W7JC2W0YVcaVmLXIeYF8A=
|
github.com/siyuan-note/riff v0.0.0-20221228031102-17d458a1217b/go.mod h1:WnNt0JPjfXp2fjAgbF9rS5W7JC2W0YVcaVmLXIeYF8A=
|
||||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
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/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY=
|
github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY=
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/88250/lute"
|
"github.com/88250/lute"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
"github.com/88250/lute/parse"
|
"github.com/88250/lute/parse"
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/riff"
|
"github.com/siyuan-note/riff"
|
||||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||||
@ -78,8 +79,9 @@ func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err err
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Flashcard struct {
|
type Flashcard struct {
|
||||||
DeckID string `json:"deckID"`
|
DeckID string `json:"deckID"`
|
||||||
BlockID string `json:"blockID"`
|
BlockID string `json:"blockID"`
|
||||||
|
NextDues map[riff.Rating]string `json:"nextDues"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
|
func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
|
||||||
@ -97,15 +99,23 @@ func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
|
|||||||
|
|
||||||
deck := Decks[deckID]
|
deck := Decks[deckID]
|
||||||
cards := deck.Dues()
|
cards := deck.Dues()
|
||||||
|
now := time.Now()
|
||||||
for _, card := range cards {
|
for _, card := range cards {
|
||||||
blockID := card.BlockID()
|
blockID := card.BlockID()
|
||||||
|
|
||||||
if nil == treenode.GetBlockTree(blockID) {
|
if nil == treenode.GetBlockTree(blockID) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextDues := map[riff.Rating]string{}
|
||||||
|
for rating, due := range card.NextDues() {
|
||||||
|
nextDues[rating] = strings.TrimSpace(humanize.RelTime(due, now, "", ""))
|
||||||
|
}
|
||||||
|
|
||||||
ret = append(ret, &Flashcard{
|
ret = append(ret, &Flashcard{
|
||||||
DeckID: deckID,
|
DeckID: deckID,
|
||||||
BlockID: blockID,
|
BlockID: blockID,
|
||||||
|
NextDues: nextDues,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if 1 > len(ret) {
|
if 1 > len(ret) {
|
||||||
@ -116,6 +126,7 @@ func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
|
|||||||
|
|
||||||
func getAllDueFlashcards() (ret []*Flashcard, err error) {
|
func getAllDueFlashcards() (ret []*Flashcard, err error) {
|
||||||
blockIDs := map[string]bool{}
|
blockIDs := map[string]bool{}
|
||||||
|
now := time.Now()
|
||||||
for _, deck := range Decks {
|
for _, deck := range Decks {
|
||||||
cards := deck.Dues()
|
cards := deck.Dues()
|
||||||
for _, card := range cards {
|
for _, card := range cards {
|
||||||
@ -128,9 +139,15 @@ func getAllDueFlashcards() (ret []*Flashcard, err error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextDues := map[riff.Rating]string{}
|
||||||
|
for rating, due := range card.NextDues() {
|
||||||
|
nextDues[rating] = strings.TrimSpace(humanize.RelTime(due, now, "", ""))
|
||||||
|
}
|
||||||
|
|
||||||
ret = append(ret, &Flashcard{
|
ret = append(ret, &Flashcard{
|
||||||
DeckID: deck.ID,
|
DeckID: deck.ID,
|
||||||
BlockID: blockID,
|
BlockID: blockID,
|
||||||
|
NextDues: nextDues,
|
||||||
})
|
})
|
||||||
blockIDs[blockID] = true
|
blockIDs[blockID] = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user