fix: 恢复时间桶的收集逻辑

This commit is contained in:
yarnom 2025-08-20 11:55:00 +08:00
parent 03d42ac3eb
commit c55f089247

View File

@ -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) + INTERVAL '1 hour' +
date_trunc('hour', timestamp) +
INTERVAL '%s' * FLOOR(EXTRACT(EPOCH FROM timestamp - date_trunc('hour', timestamp)) / EXTRACT(EPOCH FROM INTERVAL '%s')) as time_bucket,
temperature,
humidity,