Selaa lähdekoodia

:art: De-duplication of backlinks after referencing multiple blocks in the same block https://github.com/siyuan-note/siyuan/issues/12147

Daniel 10 kuukautta sitten
vanhempi
commit
4a7eb70d1a
1 muutettua tiedostoa jossa 8 lisäystä ja 5 poistoa
  1. 8 5
      kernel/model/backlink.go

+ 8 - 5
kernel/model/backlink.go

@@ -79,7 +79,7 @@ func GetBackmentionDoc(defID, refTreeID, keyword string, containChildren bool) (
 	rootID := sqlBlock.RootID
 	rootID := sqlBlock.RootID
 
 
 	refs := sql.QueryRefsByDefID(defID, containChildren)
 	refs := sql.QueryRefsByDefID(defID, containChildren)
-	refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
+	refs = removeDuplicatedRefs(refs)
 
 
 	linkRefs, _, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
 	linkRefs, _, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
 	tmpMentions, mentionKeywords := buildTreeBackmention(sqlBlock, linkRefs, keyword, excludeBacklinkIDs, beforeLen)
 	tmpMentions, mentionKeywords := buildTreeBackmention(sqlBlock, linkRefs, keyword, excludeBacklinkIDs, beforeLen)
@@ -130,7 +130,7 @@ func GetBacklinkDoc(defID, refTreeID, keyword string, containChildren bool) (ret
 			refs = append(refs, ref)
 			refs = append(refs, ref)
 		}
 		}
 	}
 	}
-	refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
+	refs = removeDuplicatedRefs(refs)
 
 
 	linkRefs, _, _ := buildLinkRefs(rootID, refs, keyword)
 	linkRefs, _, _ := buildLinkRefs(rootID, refs, keyword)
 	refTree, err := LoadTreeByBlockID(refTreeID)
 	refTree, err := LoadTreeByBlockID(refTreeID)
@@ -254,7 +254,7 @@ func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode
 	boxID = sqlBlock.Box
 	boxID = sqlBlock.Box
 
 
 	refs := sql.QueryRefsByDefID(id, true)
 	refs := sql.QueryRefsByDefID(id, true)
-	refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
+	refs = removeDuplicatedRefs(refs)
 
 
 	linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
 	linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs, keyword)
 	tmpBacklinks := toFlatTree(linkRefs, 0, "backlink", nil)
 	tmpBacklinks := toFlatTree(linkRefs, 0, "backlink", nil)
@@ -353,7 +353,7 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID strin
 
 
 	var links []*Block
 	var links []*Block
 	refs := sql.QueryRefsByDefID(id, true)
 	refs := sql.QueryRefsByDefID(id, true)
-	refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
+	refs = removeDuplicatedRefs(refs)
 
 
 	// 为了减少查询,组装好 IDs 后一次查出
 	// 为了减少查询,组装好 IDs 后一次查出
 	defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
 	defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
@@ -564,10 +564,13 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keyword string) (ret []*Bl
 }
 }
 
 
 func removeDuplicatedRefs(refs []*sql.Ref) (ret []*sql.Ref) {
 func removeDuplicatedRefs(refs []*sql.Ref) (ret []*sql.Ref) {
+	// 同一个块中引用多个块后反链去重
+	// De-duplication of backlinks after referencing multiple blocks in the same block https://github.com/siyuan-note/siyuan/issues/12147
+
 	for _, ref := range refs {
 	for _, ref := range refs {
 		contain := false
 		contain := false
 		for _, r := range ret {
 		for _, r := range ret {
-			if ref.DefBlockID == r.DefBlockID && ref.BlockID == r.BlockID {
+			if ref.BlockID == r.BlockID {
 				contain = true
 				contain = true
 				break
 				break
 			}
 			}