From a65f46c922ed93bfc22abae0d8b68c8ebda04659 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 29 Nov 2025 00:01:30 +0800 Subject: [PATCH] :bug: https://github.com/siyuan-note/siyuan/issues/16463 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/file.go | 8 +++++--- kernel/model/graph.go | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index de0bf09f7..5e1f3c2ab 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1074,6 +1074,8 @@ func CreateWithMarkdown(tags, boxID, hPath, md, parentID, id string, withMath bo return } +const DailyNoteAttrPrefix = "custom-dailynote-" + func CreateDailyNote(boxID string) (p string, existed bool, err error) { createDocLock.Lock() defer createDocLock.Unlock() @@ -1110,8 +1112,8 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) { } p = tree.Path date := time.Now().Format("20060102") - if tree.Root.IALAttr("custom-dailynote-"+date) == "" { - tree.Root.SetIALAttr("custom-dailynote-"+date, date) + if tree.Root.IALAttr(DailyNoteAttrPrefix+date) == "" { + tree.Root.SetIALAttr(DailyNoteAttrPrefix+date, date) if err = indexWriteTreeUpsertQueue(tree); err != nil { return } @@ -1179,7 +1181,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) { } p = tree.Path date := time.Now().Format("20060102") - tree.Root.SetIALAttr("custom-dailynote-"+date, date) + tree.Root.SetIALAttr(DailyNoteAttrPrefix+date, date) if err = indexWriteTreeUpsertQueue(tree); err != nil { return } diff --git a/kernel/model/graph.go b/kernel/model/graph.go index 515f01d13..f051a9818 100644 --- a/kernel/model/graph.go +++ b/kernel/model/graph.go @@ -126,17 +126,17 @@ func BuildTreeGraph(id, query string) (boxID string, nodes []*GraphNode, links [ refBlocks := fromSQLBlocks(&sqlRefBs, "", 0) if 0 < len(dailyNotesPaths) { - filterDailyNote := false + isDailyNote := false var tmp []*Block for _, refBlock := range refBlocks { for _, dailyNotePath := range dailyNotesPaths { if strings.HasPrefix(refBlock.HPath, dailyNotePath) { - filterDailyNote = true + isDailyNote = true break } } - if !filterDailyNote { + if !isDailyNote { tmp = append(tmp, refBlock) } } @@ -149,6 +149,7 @@ func BuildTreeGraph(id, query string) (boxID string, nodes []*GraphNode, links [ } } + blocks = filterDailyNote(blocks, true) genTreeNodes(blocks, &nodes, &links, true) growTreeGraph(&forwardlinks, &backlinks, &nodes) blocks = append(blocks, forwardlinks...) @@ -187,6 +188,7 @@ func BuildGraph(query string) (boxID string, nodes []*GraphNode, links []*GraphL sqlBlocks := sql.GetAllChildBlocks(rootIDs, stmt, Conf.Graph.MaxBlocks) treeBlocks := fromSQLBlocks(&sqlBlocks, "", 0) + treeBlocks = filterDailyNote(treeBlocks, false) genTreeNodes(treeBlocks, &nodes, &links, false) blocks = append(blocks, treeBlocks...) @@ -598,6 +600,34 @@ func graphTypeFilter(local bool) string { return " AND ref.type IN (" + strings.Join(inList, ",") + ")" } +func filterDailyNote(blocks []*Block, local bool) (ret []*Block) { + // Graph dailynote filtering not working https://github.com/siyuan-note/siyuan/issues/16463 + + dailyNote := Conf.Graph.Local.DailyNote + if !local { + dailyNote = Conf.Graph.Global.DailyNote + } + + if dailyNote { + ret = blocks + return + } + + for _, block := range blocks { + isDailyNote := false + for k, _ := range block.IAL { + isDailyNote = strings.HasPrefix(k, DailyNoteAttrPrefix) + if isDailyNote { + break + } + } + if !isDailyNote { + ret = append(ret, block) + } + } + return +} + func graphDailyNoteFilter(local bool) string { dailyNotesPaths := dailyNotePaths(local) if 1 > len(dailyNotesPaths) {