From be6380cbf7f3384d2da7dfdce18233def6b47fca Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 2 Nov 2022 20:01:07 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=95=B0=E6=8D=AE=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=AF=8F=E9=A1=B5=E6=9C=80=E5=90=8E=E4=B8=80=E6=9D=A1=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=B6=E9=97=B4=E5=BC=82=E5=B8=B8=20Fix=20https://g?= =?UTF-8?q?ithub.com/siyuan-note/siyuan/issues/6455?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/history.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/model/history.go b/kernel/model/history.go index 78d735e6f..653ef894a 100644 --- a/kernel/model/history.go +++ b/kernel/model/history.go @@ -317,8 +317,7 @@ func FullTextSearchHistory(query, box, op string, typ, page int) (ret []*History } pageSize := 32 - from := (page - 1) * pageSize - to := page * pageSize + offset := (page - 1) * pageSize table := "histories_fts_case_insensitive" stmt := "SELECT * FROM " + table + " WHERE " @@ -341,7 +340,7 @@ func FullTextSearchHistory(query, box, op string, typ, page int) (ret []*History stmt += " AND path LIKE '%/assets/%'" } countStmt := strings.ReplaceAll(stmt, "SELECT *", "SELECT COUNT(*) AS total") - stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(from) + ", " + strconv.Itoa(to) + stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(pageSize) + " OFFSET " + strconv.Itoa(offset) sqlHistories := sql.SelectHistoriesRawStmt(stmt) ret = fromSQLHistories(sqlHistories) result, err := sql.QueryHistory(countStmt) @@ -660,12 +659,9 @@ func fromSQLHistories(sqlHistories []*sql.History) (ret []*History) { } var items []*HistoryItem - var tmpTime int64 + tmpTime, _ := strconv.ParseInt(sqlHistories[0].Created, 10, 64) for _, sqlHistory := range sqlHistories { unixSec, _ := strconv.ParseInt(sqlHistory.Created, 10, 64) - if 0 == tmpTime { - tmpTime = unixSec - } if tmpTime == unixSec { item := &HistoryItem{ Title: sqlHistory.Title, @@ -691,6 +687,7 @@ func fromSQLHistories(sqlHistories []*sql.History) (ret []*History) { items = []*HistoryItem{} items = append(items, item) } + tmpTime = unixSec } if 0 < len(items) { ret = append(ret, &History{