An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add Relation column to database table view https://github.com/siyuan-note/siyuan/issues/9888
Danielfb72af192e13
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 1cc37e236b..3fc696aa6d 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -33,6 +33,7 @@ import ("github.com/siyuan-note/filelock""github.com/siyuan-note/logging""github.com/siyuan-note/siyuan/kernel/av"+ "github.com/siyuan-note/siyuan/kernel/sql""github.com/siyuan-note/siyuan/kernel/treenode""github.com/siyuan-note/siyuan/kernel/util")@@ -52,9 +53,20 @@ type SearchAttributeViewResult struct {func SearchAttributeView(keyword string, page int, pageSize int) (ret []*SearchAttributeViewResult, pageCount int) {waitForSyncingStorages()-ret = []*SearchAttributeViewResult{}- blocks, _, _, pageCount := FullTextSearchBlock(keyword, nil, nil, map[string]bool{"databaseBlock": true}, 0, 7, 0, page, pageSize)++ var blocks []*Block+ keyword = strings.TrimSpace(keyword)+ if "" == keyword {+ sqlBlocks := sql.SelectBlocksRawStmt("SELECT * FROM blocks WHERE type = 'av' ORDER BY updated DESC LIMIT 10", page, pageSize)+ blocks = fromSQLBlocks(&sqlBlocks, "", 36)+ pageCount = 1+ } else {+ var matchedBlockCount int+ blocks, matchedBlockCount, _ = fullTextSearchByKeyword(keyword, "", "", "('av')", "", 36, page, pageSize)+ pageCount = (matchedBlockCount + pageSize - 1) / pageSize+ }+trees := map[string]*parse.Tree{}for _, block := range blocks {tree := trees[block.RootID]@@ -154,7 +166,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {}}- // 渲染自动生成的列值,比如模板列、创建时间列和更新时间列+ // 渲染自动生成的列值,比如模板列、关联列、汇总列、创建时间列和更新时间列// 先处理创建时间和更新时间for _, kv := range keyValues {switch kv.Key.Type {@@ -647,7 +659,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *aret.Rows = append(ret.Rows, &tableRow)}- // 渲染自动生成的列值,比如模板列、创建时间列和更新时间列+ // 渲染自动生成的列值,比如模板列、关联列、汇总列、创建时间列和更新时间列for _, row := range ret.Rows {for _, cell := range row.Cells {switch cell.ValueType {@@ -660,6 +672,11 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a}content := renderTemplateCol(ial, cell.Value.Template.Content, keyValues)cell.Value.Template.Content = content+ case av.KeyTypeRelation: // 渲染关联列++ //for _, blockID := range cell.Value.Relation.BlockIDs {+ //+ //}case av.KeyTypeCreated: // 渲染创建时间createdStr := row.ID[:len("20060102150405")]created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)diff --git a/kernel/treenode/node.go b/kernel/treenode/node.goindex 5bca7a517f..f153057442 100644--- a/kernel/treenode/node.go+++ b/kernel/treenode/node.go@@ -708,7 +708,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *aret.Rows = append(ret.Rows, &tableRow)}- // 渲染自动生成的列值,比如模板列、创建时间列和更新时间列+ // 渲染自动生成的列值,比如模板列、关联列、汇总列、创建时间列和更新时间列for _, row := range ret.Rows {for _, cell := range row.Cells {switch cell.ValueType {