⚡ Improve database table view update time column rendering performance https://github.com/siyuan-note/siyuan/issues/9719
This commit is contained in:
parent
72752f441a
commit
5c182e2ea7
2 changed files with 30 additions and 5 deletions
|
@ -45,7 +45,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
|||
waitForSyncingStorages()
|
||||
|
||||
ret = []*BlockAttributeViewKeys{}
|
||||
attrs := GetBlockAttrs(blockID)
|
||||
attrs := GetBlockAttrsWithoutWaitWriting(blockID)
|
||||
avs := attrs[av.NodeAttrNameAvs]
|
||||
if "" == avs {
|
||||
return
|
||||
|
@ -102,7 +102,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
|||
kv.Values[0].Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
|
||||
}
|
||||
case av.KeyTypeUpdated:
|
||||
ial := GetBlockAttrs(blockID)
|
||||
ial := GetBlockAttrsWithoutWaitWriting(blockID)
|
||||
updatedStr := ial["updated"]
|
||||
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
|
||||
if nil == parseErr {
|
||||
|
@ -122,7 +122,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
|||
ial := map[string]string{}
|
||||
block := getRowBlockValue(keyValues)
|
||||
if !block.IsDetached {
|
||||
ial = GetBlockAttrs(blockID)
|
||||
ial = GetBlockAttrsWithoutWaitWriting(blockID)
|
||||
}
|
||||
kv.Values[0].Template.Content = renderTemplateCol(ial, kv.Key.Template, keyValues)
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
ial := map[string]string{}
|
||||
block := row.GetBlockValue()
|
||||
if !block.IsDetached {
|
||||
ial = GetBlockAttrs(row.ID)
|
||||
ial = GetBlockAttrsWithoutWaitWriting(row.ID)
|
||||
}
|
||||
content := renderTemplateCol(ial, cell.Value.Template.Content, keyValues)
|
||||
cell.Value.Template.Content = content
|
||||
|
@ -481,7 +481,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
ial := map[string]string{}
|
||||
block := row.GetBlockValue()
|
||||
if !block.IsDetached {
|
||||
ial = GetBlockAttrs(row.ID)
|
||||
ial = GetBlockAttrsWithoutWaitWriting(row.ID)
|
||||
}
|
||||
updatedStr := ial["updated"]
|
||||
if "" == updatedStr {
|
||||
|
|
|
@ -268,3 +268,28 @@ func GetBlockAttrs(id string) (ret map[string]string) {
|
|||
cache.PutBlockIAL(id, ret)
|
||||
return
|
||||
}
|
||||
|
||||
func GetBlockAttrsWithoutWaitWriting(id string) (ret map[string]string) {
|
||||
ret = map[string]string{}
|
||||
if cached := cache.GetBlockIAL(id); nil != cached {
|
||||
ret = cached
|
||||
return
|
||||
}
|
||||
|
||||
tree, err := loadTreeByBlockID(id)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
if nil == node {
|
||||
logging.LogWarnf("block [%s] not found", id)
|
||||
return
|
||||
}
|
||||
|
||||
for _, kv := range node.KramdownIAL {
|
||||
ret[kv[0]] = html.UnescapeAttrVal(kv[1])
|
||||
}
|
||||
cache.PutBlockIAL(id, ret)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue