mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
d19cd19f44
commit
7682cc447b
1 changed files with 5 additions and 4 deletions
|
|
@ -176,7 +176,7 @@ func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) {
|
||||||
refs := sql.QueryRefsByDefID(defID, true)
|
refs := sql.QueryRefsByDefID(defID, true)
|
||||||
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
||||||
|
|
||||||
linkRefs, excludeBacklinkIDs := buildLinkRefs(rootID, refs)
|
linkRefs, _, excludeBacklinkIDs := buildLinkRefs(rootID, refs)
|
||||||
tmpMentions := buildTreeBackmention(sqlBlock, linkRefs, keyword, excludeBacklinkIDs, beforeLen)
|
tmpMentions := buildTreeBackmention(sqlBlock, linkRefs, keyword, excludeBacklinkIDs, beforeLen)
|
||||||
luteEngine := NewLute()
|
luteEngine := NewLute()
|
||||||
treeCache := map[string]*parse.Tree{}
|
treeCache := map[string]*parse.Tree{}
|
||||||
|
|
@ -221,7 +221,7 @@ func GetBacklinkDoc(defID, refTreeID string) (ret []*Backlink) {
|
||||||
}
|
}
|
||||||
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
||||||
|
|
||||||
linkRefs, _ := buildLinkRefs(rootID, refs)
|
linkRefs, _, _ := buildLinkRefs(rootID, refs)
|
||||||
refTree, err := loadTreeByBlockID(refTreeID)
|
refTree, err := loadTreeByBlockID(refTreeID)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogWarnf("load ref tree [%s] failed: %s", refTreeID, err)
|
logging.LogWarnf("load ref tree [%s] failed: %s", refTreeID, err)
|
||||||
|
|
@ -236,7 +236,7 @@ func GetBacklinkDoc(defID, refTreeID string) (ret []*Backlink) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildLinkRefs(defRootID string, refs []*sql.Ref) (ret []*Block, excludeBacklinkIDs *hashset.Set) {
|
func buildLinkRefs(defRootID string, refs []*sql.Ref) (ret []*Block, refsCount int, excludeBacklinkIDs *hashset.Set) {
|
||||||
// 为了减少查询,组装好 IDs 后一次查出
|
// 为了减少查询,组装好 IDs 后一次查出
|
||||||
defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
|
defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
|
||||||
var queryBlockIDs []string
|
var queryBlockIDs []string
|
||||||
|
|
@ -289,6 +289,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref) (ret []*Block, excludeBack
|
||||||
for _, ref := range link.Refs {
|
for _, ref := range link.Refs {
|
||||||
excludeBacklinkIDs.Add(ref.RootID, ref.ID)
|
excludeBacklinkIDs.Add(ref.RootID, ref.ID)
|
||||||
}
|
}
|
||||||
|
refsCount += len(link.Refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
processedParagraphs := hashset.New()
|
processedParagraphs := hashset.New()
|
||||||
|
|
@ -396,7 +397,7 @@ func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID
|
||||||
refs := sql.QueryRefsByDefID(id, true)
|
refs := sql.QueryRefsByDefID(id, true)
|
||||||
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
||||||
|
|
||||||
linkRefs, excludeBacklinkIDs := buildLinkRefs(id, refs)
|
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(id, refs)
|
||||||
backlinks = toFlatTree(linkRefs, 0, "backlink")
|
backlinks = toFlatTree(linkRefs, 0, "backlink")
|
||||||
for _, l := range backlinks {
|
for _, l := range backlinks {
|
||||||
l.Blocks = nil
|
l.Blocks = nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue