mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 20:00:26 +08:00
⚡ Improve performance for rendering databases, due flashcards
This commit is contained in:
parent
65f24b376e
commit
06f3721fd4
@ -244,7 +244,7 @@ func openNotebook(c *gin.Context) {
|
|||||||
"20240530133126-axarxgx": "20240530101000-4qitucx",
|
"20240530133126-axarxgx": "20240530101000-4qitucx",
|
||||||
}
|
}
|
||||||
startID = guideStartID[notebook]
|
startID = guideStartID[notebook]
|
||||||
if nil != treenode.GetBlockTree(startID) {
|
if treenode.ExistBlockTree(startID) {
|
||||||
util.BroadcastByTypeAndApp("main", app, "openFileById", 0, "", map[string]interface{}{
|
util.BroadcastByTypeAndApp("main", app, "openFileById", 0, "", map[string]interface{}{
|
||||||
"id": startID,
|
"id": startID,
|
||||||
})
|
})
|
||||||
|
@ -199,7 +199,7 @@ func GetAttributeViewPrimaryKeyValues(avID, keyword string, page, pageSize int)
|
|||||||
switch view.LayoutType {
|
switch view.LayoutType {
|
||||||
case av.LayoutTypeTable:
|
case av.LayoutTypeTable:
|
||||||
if !kv.IsDetached {
|
if !kv.IsDetached {
|
||||||
if nil == treenode.GetBlockTree(kv.BlockID) {
|
if !treenode.ExistBlockTree(kv.BlockID) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,17 +71,17 @@ func GetDocInfo(blockID string) (ret *BlockInfo) {
|
|||||||
delete(ret.IAL, "scroll")
|
delete(ret.IAL, "scroll")
|
||||||
} else {
|
} else {
|
||||||
if zoomInId := scroll["zoomInId"]; nil != zoomInId {
|
if zoomInId := scroll["zoomInId"]; nil != zoomInId {
|
||||||
if nil == treenode.GetBlockTree(zoomInId.(string)) {
|
if !treenode.ExistBlockTree(zoomInId.(string)) {
|
||||||
delete(ret.IAL, "scroll")
|
delete(ret.IAL, "scroll")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if startId := scroll["startId"]; nil != startId {
|
if startId := scroll["startId"]; nil != startId {
|
||||||
if nil == treenode.GetBlockTree(startId.(string)) {
|
if !treenode.ExistBlockTree(startId.(string)) {
|
||||||
delete(ret.IAL, "scroll")
|
delete(ret.IAL, "scroll")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if endId := scroll["endId"]; nil != endId {
|
if endId := scroll["endId"]; nil != endId {
|
||||||
if nil == treenode.GetBlockTree(endId.(string)) {
|
if !treenode.ExistBlockTree(endId.(string)) {
|
||||||
delete(ret.IAL, "scroll")
|
delete(ret.IAL, "scroll")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1085,7 +1085,7 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCar
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil == treenode.GetBlockTree(c.BlockID()) {
|
if !treenode.ExistBlockTree(c.BlockID()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
|
|||||||
|
|
||||||
// 过滤掉不存在的行
|
// 过滤掉不存在的行
|
||||||
var notFound []string
|
var notFound []string
|
||||||
|
var toCheckBlockIDs []string
|
||||||
for blockID, keyValues := range rows {
|
for blockID, keyValues := range rows {
|
||||||
blockValue := getRowBlockValue(keyValues)
|
blockValue := getRowBlockValue(keyValues)
|
||||||
if nil == blockValue {
|
if nil == blockValue {
|
||||||
@ -127,7 +128,11 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil == treenode.GetBlockTree(blockID) {
|
toCheckBlockIDs = append(toCheckBlockIDs, blockID)
|
||||||
|
}
|
||||||
|
checkRet := treenode.ExistBlockTrees(toCheckBlockIDs)
|
||||||
|
for blockID, exist := range checkRet {
|
||||||
|
if !exist {
|
||||||
notFound = append(notFound, blockID)
|
notFound = append(notFound, blockID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,6 +304,30 @@ func ExistBlockTree(id string) bool {
|
|||||||
return 0 < count
|
return 0 < count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExistBlockTrees(ids []string) (ret map[string]bool) {
|
||||||
|
ret = map[string]bool{}
|
||||||
|
for _, id := range ids {
|
||||||
|
ret[id] = false
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlStmt := "SELECT id FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
|
||||||
|
rows, err := db.Query(sqlStmt)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var id string
|
||||||
|
if err = rows.Scan(&id); nil != err {
|
||||||
|
logging.LogErrorf("query scan field failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ret[id] = true
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetBlockTrees(ids []string) (ret map[string]*BlockTree) {
|
func GetBlockTrees(ids []string) (ret map[string]*BlockTree) {
|
||||||
ret = map[string]*BlockTree{}
|
ret = map[string]*BlockTree{}
|
||||||
sqlStmt := "SELECT * FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
|
sqlStmt := "SELECT * FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
|
||||||
|
Loading…
Reference in New Issue
Block a user