Daniel 2025-09-08 10:56:54 +08:00
parent de9e648e9e
commit a4f03191fa
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 3 additions and 3 deletions

View file

@ -187,7 +187,7 @@ func SearchDocsByKeyword(keyword string, flashcard bool) (ret []map[string]strin
}
}
rootBlocks = sql.QueryRootBlockByCondition(condition)
rootBlocks = sql.QueryRootBlockByCondition(condition, Conf.Search.Limit)
} else {
for _, box := range boxes {
if flashcard {

View file

@ -69,8 +69,8 @@ func queryBlockHashes(rootID string) (ret map[string]string) {
return
}
func QueryRootBlockByCondition(condition string) (ret []*Block) {
sqlStmt := "SELECT *, length(hpath) - length(replace(hpath, '/', '')) AS lv FROM blocks WHERE type = 'd' AND " + condition + " ORDER BY box DESC,lv ASC LIMIT 128"
func QueryRootBlockByCondition(condition string, limit int) (ret []*Block) {
sqlStmt := "SELECT *, length(hpath) - length(replace(hpath, '/', '')) AS lv FROM blocks WHERE type = 'd' AND " + condition + " ORDER BY box DESC,lv ASC LIMIT " + strconv.Itoa(limit)
rows, err := query(sqlStmt)
if err != nil {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)