mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 数据历史文档中支持操作类型过滤 https://github.com/siyuan-note/siyuan/issues/5754
This commit is contained in:
parent
bd0ec0dcf2
commit
5be606ad3c
3 changed files with 60 additions and 3 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
|
@ -275,7 +276,7 @@ func GetDocHistory(boxID string, page int) (ret []*History, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func FullTextSearchHistory(query, op string, page int) (ret []*History) {
|
||||
func FullTextSearchHistory(query, op string, page int) (ret []*History, pageCount, totalCount int) {
|
||||
query = gulu.Str.RemoveInvisible(query)
|
||||
query = stringQuery(query)
|
||||
|
||||
|
|
@ -288,9 +289,19 @@ func FullTextSearchHistory(query, op string, page int) (ret []*History) {
|
|||
if "all" != op {
|
||||
stmt += " AND op = '" + op + "'"
|
||||
}
|
||||
countStmt := strings.ReplaceAll(stmt, "SELECT *", "SELECT COUNT(*) AS total")
|
||||
stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(from) + ", " + strconv.Itoa(to)
|
||||
sqlHistories := sql.SelectHistoriesRawStmt(stmt)
|
||||
ret = fromSQLHistories(sqlHistories)
|
||||
result, err := sql.QueryHistory(countStmt)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
if 1 > len(result) {
|
||||
return
|
||||
}
|
||||
totalCount = int(result[0]["matches"].(int64))
|
||||
pageCount = int(math.Ceil(float64(totalCount) / float64(pageSize)))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue