mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 数据历史文档中支持操作类型过滤 https://github.com/siyuan-note/siyuan/issues/5754
This commit is contained in:
parent
3e988fa9d0
commit
bd0ec0dcf2
2 changed files with 10 additions and 4 deletions
|
|
@ -40,7 +40,11 @@ func searchHistory(c *gin.Context) {
|
||||||
if nil != arg["page"] {
|
if nil != arg["page"] {
|
||||||
page = int(arg["page"].(float64))
|
page = int(arg["page"].(float64))
|
||||||
}
|
}
|
||||||
histories := model.FullTextSearchHistory(query, page)
|
op := "all"
|
||||||
|
if nil != arg["op"] {
|
||||||
|
op = arg["op"].(string)
|
||||||
|
}
|
||||||
|
histories := model.FullTextSearchHistory(query, op, page)
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"histories": histories,
|
"histories": histories,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ func GetDocHistory(boxID string, page int) (ret []*History, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func FullTextSearchHistory(query string, page int) (ret []*History) {
|
func FullTextSearchHistory(query, op string, page int) (ret []*History) {
|
||||||
query = gulu.Str.RemoveInvisible(query)
|
query = gulu.Str.RemoveInvisible(query)
|
||||||
query = stringQuery(query)
|
query = stringQuery(query)
|
||||||
|
|
||||||
|
|
@ -284,8 +284,10 @@ func FullTextSearchHistory(query string, page int) (ret []*History) {
|
||||||
to := page * pageSize
|
to := page * pageSize
|
||||||
|
|
||||||
table := "histories_fts_case_insensitive"
|
table := "histories_fts_case_insensitive"
|
||||||
projections := "type, op, title, content, path, created"
|
stmt := "SELECT * FROM " + table + " WHERE " + table + " MATCH '{title content}:(" + query + ")'"
|
||||||
stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '{title content}:(" + query + ")'"
|
if "all" != op {
|
||||||
|
stmt += " AND op = '" + op + "'"
|
||||||
|
}
|
||||||
stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(from) + ", " + strconv.Itoa(to)
|
stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(from) + ", " + strconv.Itoa(to)
|
||||||
sqlHistories := sql.SelectHistoriesRawStmt(stmt)
|
sqlHistories := sql.SelectHistoriesRawStmt(stmt)
|
||||||
ret = fromSQLHistories(sqlHistories)
|
ret = fromSQLHistories(sqlHistories)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue