From be613883a1a944b7405f47996e92fdd65d34e9ef Mon Sep 17 00:00:00 2001 From: MartialBE Date: Fri, 22 Dec 2023 20:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20statistics=20error=20in=20?= =?UTF-8?q?SQLite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/log.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/model/log.go b/model/log.go index a8699673..f3858c3b 100644 --- a/model/log.go +++ b/model/log.go @@ -200,6 +200,10 @@ func SearchLogsByDayAndModel(user_id, start, end int) (LogStatistics []*LogStati groupSelect = "TO_CHAR(date_trunc('day', to_timestamp(created_at)), 'YYYY-MM-DD') as day" } + if common.UsingSQLite { + groupSelect = "strftime('%Y-%m-%d', datetime(created_at, 'unixepoch')) as day" + } + err = DB.Raw(` SELECT `+groupSelect+`, model_name, count(1) as request_count,