From 03d42ac3eb4ec529b28ead35b5383836c70ce17d Mon Sep 17 00:00:00 2001 From: yarnom Date: Wed, 20 Aug 2025 11:42:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=94=B9=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A1=B6=E7=9A=84=E6=94=B6=E9=9B=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_server.go b/web_server.go index 7d8e52c..57ec456 100644 --- a/web_server.go +++ b/web_server.go @@ -112,11 +112,11 @@ func getStationData(w http.ResponseWriter, r *http.Request) { intervalSQL = "1 hour" } - // 构建查询SQL - 使用时间窗口聚合 + // 构建查询SQL - 使用时间窗口聚合,显示上一个时间段的数据 query = fmt.Sprintf(` WITH time_series AS ( SELECT - date_trunc('hour', timestamp) + + date_trunc('hour', timestamp) + INTERVAL '1 hour' + INTERVAL '%s' * FLOOR(EXTRACT(EPOCH FROM timestamp - date_trunc('hour', timestamp)) / EXTRACT(EPOCH FROM INTERVAL '%s')) as time_bucket, temperature, humidity,