mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-07-03 14:09:06 +02:00
⚡ Improve database view performance https://github.com/siyuan-note/siyuan/issues/17830
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
+19
-17
@@ -434,6 +434,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
||||
}
|
||||
|
||||
// 渲染关联
|
||||
blocksCache := map[string]map[string]*av.Value{}
|
||||
for _, item := range collection.GetItems() {
|
||||
for _, value := range item.GetValues() {
|
||||
if av.KeyTypeRelation != value.Type {
|
||||
@@ -451,17 +452,21 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
||||
}
|
||||
}
|
||||
if nil != destAv {
|
||||
blocks := map[string]*av.Value{}
|
||||
blockValues := destAv.GetBlockKeyValues()
|
||||
if nil != blockValues {
|
||||
for _, blockValue := range blockValues.Values {
|
||||
blocks[blockValue.BlockID] = blockValue
|
||||
}
|
||||
for _, blockID := range value.Relation.BlockIDs {
|
||||
if val := blocks[blockID]; nil != val {
|
||||
value.Relation.Contents = append(value.Relation.Contents, val)
|
||||
blocks := blocksCache[destAv.ID]
|
||||
if nil == blocks {
|
||||
blocks = map[string]*av.Value{}
|
||||
blockValues := destAv.GetBlockKeyValues()
|
||||
if nil != blockValues {
|
||||
for _, blockValue := range blockValues.Values {
|
||||
blocks[blockValue.BlockID] = blockValue
|
||||
}
|
||||
}
|
||||
blocksCache[destAv.ID] = blocks
|
||||
}
|
||||
for _, blockID := range value.Relation.BlockIDs {
|
||||
if val := blocks[blockID]; nil != val {
|
||||
value.Relation.Contents = append(value.Relation.Contents, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -659,15 +664,12 @@ func fillAttributeViewKeyValues(attrView *av.AttributeView, collection av.Collec
|
||||
}
|
||||
for keyID, values := range fieldValues {
|
||||
keyValues, _ := attrView.GetKeyValues(keyID)
|
||||
existingIDs := map[string]bool{}
|
||||
for _, kv := range keyValues.Values {
|
||||
existingIDs[kv.ID] = true
|
||||
}
|
||||
for _, val := range values {
|
||||
exist := false
|
||||
for _, kv := range keyValues.Values {
|
||||
if kv.ID == val.ID {
|
||||
exist = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !exist {
|
||||
if !existingIDs[val.ID] {
|
||||
val.IsRenderAutoFill = true
|
||||
keyValues.Values = append(keyValues.Values, val)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user