From 1a991bf20fe826a3c45138df6fc65d82a0c445de Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 12 Jan 2025 21:19:03 +0800 Subject: [PATCH] :art: Backlink count at the doc block title including sub-blocks https://github.com/siyuan-note/siyuan/issues/13791 --- kernel/api/block.go | 5 ++--- kernel/model/blockinfo.go | 5 ++--- kernel/sql/file_annotation_ref.go | 9 ++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/kernel/api/block.go b/kernel/api/block.go index 56ac83c20..70c87c13b 100644 --- a/kernel/api/block.go +++ b/kernel/api/block.go @@ -455,10 +455,9 @@ func getRefIDsByFileAnnotationID(c *gin.Context) { } id := arg["id"].(string) - refIDs, refTexts := model.GetBlockRefIDsByFileAnnotationID(id) + refIDs := model.GetBlockRefIDsByFileAnnotationID(id) ret.Data = map[string][]string{ - "refIDs": refIDs, - "refTexts": refTexts, + "refIDs": refIDs, } } diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go index 4f92a7eb5..a6b987fa0 100644 --- a/kernel/model/blockinfo.go +++ b/kernel/model/blockinfo.go @@ -369,9 +369,8 @@ func queryDocRefDefs(rootID string) (refDefs []*RefDefs) { return } -func GetBlockRefIDsByFileAnnotationID(id string) (refIDs, refTexts []string) { - refIDs, refTexts = sql.QueryRefIDsByAnnotationID(id) - return +func GetBlockRefIDsByFileAnnotationID(id string) []string { + return sql.QueryRefIDsByAnnotationID(id) } func GetBlockDefIDsByRefText(refText string, excludeIDs []string) (ret []string) { diff --git a/kernel/sql/file_annotation_ref.go b/kernel/sql/file_annotation_ref.go index 8c1df8375..f1c2da136 100644 --- a/kernel/sql/file_annotation_ref.go +++ b/kernel/sql/file_annotation_ref.go @@ -32,22 +32,21 @@ type FileAnnotationRef struct { Type string } -func QueryRefIDsByAnnotationID(annotationID string) (refIDs, refTexts []string) { +func QueryRefIDsByAnnotationID(annotationID string) (refIDs []string) { refIDs = []string{} - rows, err := query("SELECT block_id, content FROM file_annotation_refs WHERE annotation_id = ?", annotationID) + rows, err := query("SELECT block_id FROM file_annotation_refs WHERE annotation_id = ?", annotationID) if err != nil { logging.LogErrorf("sql query failed: %s", err) return } defer rows.Close() for rows.Next() { - var id, content string - if err = rows.Scan(&id, &content); err != nil { + var id string + if err = rows.Scan(&id); err != nil { logging.LogErrorf("query scan field failed: %s", err) return } refIDs = append(refIDs, id) - refTexts = append(refTexts, content) } return }