From 294fea9aa81d367cfd5d073c2910286421885b58 Mon Sep 17 00:00:00 2001 From: DingZQ Date: Mon, 24 Feb 2025 20:29:57 +0800 Subject: [PATCH] Refine --- influxdb_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/influxdb_api.py b/influxdb_api.py index a318182..9744d02 100644 --- a/influxdb_api.py +++ b/influxdb_api.py @@ -1353,10 +1353,11 @@ def query_all_record_by_date(query_date: str, bucket: str="realtime_simulation_r query_api = client.query_api() # 将 start_date 的北京时间转换为 UTC 时间 start_time = (datetime.strptime(query_date, "%Y-%m-%d") - timedelta(days=1)).replace(hour=16, minute=0, second=0, tzinfo=timezone.utc).isoformat() + stop_time = start_time + timedelta(hours=2) # 构建 Flux 查询语句 flux_query = f''' from(bucket: "{bucket}") - |> range(start: {start_time}) + |> range(start: {start_time}, stop: {stop_time}) |> filter(fn: (r) => r["_measurement"] == "node" or r["_measurement"] == "link") |> filter(fn: (r) => r["date"] == "{query_date}") |> pivot(