This commit is contained in:
Daniel 2024-11-22 23:27:38 +08:00
parent 83b932478e
commit a48609755e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 10 additions and 8 deletions

View file

@ -726,7 +726,7 @@ func scanBlockRow(row *sql.Row) (ret *Block) {
return
}
func GetChildBlocks(parentID, condition string) (ret []*Block) {
func GetChildBlocks(parentID, condition string, limit int) (ret []*Block) {
blockIDs := queryBlockChildrenIDs(parentID)
var params []string
for _, id := range blockIDs {
@ -738,6 +738,7 @@ func GetChildBlocks(parentID, condition string) (ret []*Block) {
if "" != condition {
sqlStmt += " AND " + condition
}
sqlStmt += " LIMIT " + strconv.Itoa(limit)
rows, err := query(sqlStmt)
if err != nil {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
@ -752,12 +753,13 @@ func GetChildBlocks(parentID, condition string) (ret []*Block) {
return
}
func GetAllChildBlocks(rootIDs []string, condition string) (ret []*Block) {
func GetAllChildBlocks(rootIDs []string, condition string, limit int) (ret []*Block) {
ret = []*Block{}
sqlStmt := "SELECT * FROM blocks AS ref WHERE ref.root_id IN ('" + strings.Join(rootIDs, "','") + "')"
if "" != condition {
sqlStmt += " AND " + condition
}
sqlStmt += " LIMIT " + strconv.Itoa(limit)
rows, err := query(sqlStmt)
if err != nil {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)