diff --git a/kernel/av/table.go b/kernel/av/table.go index 1370a18a4..69b161efe 100644 --- a/kernel/av/table.go +++ b/kernel/av/table.go @@ -176,9 +176,11 @@ func (value *Value) Compare(other *Value) int { } case KeyTypeTemplate: if nil != value.Template && nil != other.Template { - if util.IsNumeric(value.Template.Content) && util.IsNumeric(other.Template.Content) { - v1, _ := strconv.ParseFloat(value.Template.Content, 64) - v2, _ := strconv.ParseFloat(other.Template.Content, 64) + vContent := strings.TrimSpace(value.Template.Content) + oContent := strings.TrimSpace(other.Template.Content) + if util.IsNumeric(vContent) && util.IsNumeric(oContent) { + v1, _ := strconv.ParseFloat(vContent, 64) + v2, _ := strconv.ParseFloat(oContent, 64) if v1 > v2 { return 1 } diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 1d041c609..306208e54 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -492,8 +492,7 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Fl cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs, Conf.Flashcard.NewCardLimit, Conf.Flashcard.ReviewCardLimit) now := time.Now() for _, card := range cards { - blockID := card.BlockID() - ret = append(ret, newFlashcard(card, blockID, builtinDeckID, now)) + ret = append(ret, newFlashcard(card, card.BlockID(), builtinDeckID, now)) } if 1 > len(ret) { ret = []*Flashcard{} @@ -536,8 +535,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs, newCardLimit, reviewCardLimit) now := time.Now() for _, card := range cards { - blockID := card.BlockID() - ret = append(ret, newFlashcard(card, blockID, builtinDeckID, now)) + ret = append(ret, newFlashcard(card, card.BlockID(), builtinDeckID, now)) } if 1 > len(ret) { ret = []*Flashcard{} @@ -606,13 +604,7 @@ func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, nil, Conf.Flashcard.NewCardLimit, Conf.Flashcard.ReviewCardLimit) now := time.Now() for _, card := range cards { - blockID := card.BlockID() - - if nil == treenode.GetBlockTree(blockID) { - continue - } - - ret = append(ret, newFlashcard(card, blockID, deckID, now)) + ret = append(ret, newFlashcard(card, card.BlockID(), deckID, now)) } if 1 > len(ret) { ret = []*Flashcard{} @@ -627,12 +619,7 @@ func getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard, unreviewed cards, unreviewedCnt := getDeckDueCards(deck, reviewedCardIDs, nil, Conf.Flashcard.NewCardLimit, Conf.Flashcard.ReviewCardLimit) unreviewedCount += unreviewedCnt for _, card := range cards { - blockID := card.BlockID() - if nil == treenode.GetBlockTree(blockID) { - continue - } - - ret = append(ret, newFlashcard(card, blockID, deck.ID, now)) + ret = append(ret, newFlashcard(card, card.BlockID(), deck.ID, now)) } } if 1 > len(ret) { @@ -997,6 +984,14 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCar dues := deck.Dues() var tmp []riff.Card + for _, c := range dues { + if nil == treenode.GetBlockTree(c.BlockID()) { + continue + } + tmp = append(tmp, c) + } + dues = tmp + for _, c := range dues { if 0 < len(blockIDs) && !gulu.Str.Contains(c.BlockID(), blockIDs) { continue diff --git a/kernel/model/import.go b/kernel/model/import.go index 1ed0ce561..04116b306 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -147,7 +147,9 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { return ast.WalkContinue } - newNodeID := ast.NewNodeID() + // 新 ID 保留时间部分,仅修改随机值,避免时间变化导致更新时间早于创建时间 + // Keep original creation time when importing .sy.zip https://github.com/siyuan-note/siyuan/issues/9923 + newNodeID := util.TimeFromID(n.ID) + "-" + gulu.Rand.String(7) blockIDs[n.ID] = newNodeID oldNodeID := n.ID n.ID = newNodeID