🎨 Support for opening file history on the doc tree https://github.com/siyuan-note/siyuan/issues/8448

This commit is contained in:
Daniel 2023-06-04 09:35:48 +08:00
parent abf7b57827
commit 17d8c79057
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 8 additions and 7 deletions

View file

@ -139,7 +139,7 @@ export const openDocHistory = (options: {
event.preventDefault();
break;
} else if (target.classList.contains("b3-list-item") && !isLoading) {
getHistoryPath(target, opElement.value, options.notebookId, (dataPath) => {
getHistoryPath(target, opElement.value, options.id, (dataPath) => {
fetchPost("/api/history/getDocHistoryContent", {
historyPath: dataPath,
}, (response) => {

View file

@ -311,20 +311,21 @@ type HistoryItem struct {
Path string `json:"path"`
}
const fileHistoryPageSize = 32
func FullTextSearchHistory(query, box, op string, typ, page int) (ret []string, pageCount, totalCount int) {
query = gulu.Str.RemoveInvisible(query)
if "" != query && HistoryTypeDocID != typ {
query = stringQuery(query)
}
pageSize := 32
offset := (page - 1) * pageSize
offset := (page - 1) * fileHistoryPageSize
table := "histories_fts_case_insensitive"
stmt := "SELECT DISTINCT created FROM " + table + " WHERE "
stmt += buildSearchHistoryQueryFilter(query, op, box, table, typ)
countStmt := strings.ReplaceAll(stmt, "SELECT DISTINCT created", "SELECT COUNT(DISTINCT created) AS total")
stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(pageSize) + " OFFSET " + strconv.Itoa(offset)
stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(fileHistoryPageSize) + " OFFSET " + strconv.Itoa(offset)
result, err := sql.QueryHistory(stmt)
if nil != err {
return
@ -343,20 +344,20 @@ func FullTextSearchHistory(query, box, op string, typ, page int) (ret []string,
return
}
totalCount = int(result[0]["total"].(int64))
pageCount = int(math.Ceil(float64(totalCount) / float64(pageSize)))
pageCount = int(math.Ceil(float64(totalCount) / float64(fileHistoryPageSize)))
return
}
func FullTextSearchHistoryItems(created, query, box, op string, typ int) (ret []*HistoryItem) {
query = gulu.Str.RemoveInvisible(query)
if "" != query {
if "" != query && HistoryTypeDocID != typ {
query = stringQuery(query)
}
table := "histories_fts_case_insensitive"
stmt := "SELECT * FROM " + table + " WHERE "
stmt += buildSearchHistoryQueryFilter(query, op, box, table, typ)
stmt += " AND created = '" + created + "' ORDER BY created DESC LIMIT " + fmt.Sprintf("%d", Conf.Search.Limit)
stmt += " AND created = '" + created + "' ORDER BY created DESC LIMIT " + fmt.Sprintf("%d", fileHistoryPageSize)
sqlHistories := sql.SelectHistoriesRawStmt(stmt)
ret = fromSQLHistories(sqlHistories)
return