From 2d3799f10e0067dbe317f9bb735a3182f496fa11 Mon Sep 17 00:00:00 2001 From: DingZQ Date: Tue, 4 Mar 2025 21:20:33 +0800 Subject: [PATCH] Refine --- influxdb_api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/influxdb_api.py b/influxdb_api.py index 951131d..4ae6a9d 100644 --- a/influxdb_api.py +++ b/influxdb_api.py @@ -1800,16 +1800,20 @@ def query_all_record_by_date_property(query_date: str, type: str, property: str, else: raise ValueError(f"不支持的类型: {type}") # 将 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() + start_time = (datetime.strptime(query_date, "%Y-%m-%d") - timedelta(days=1)).replace(hour=16, minute=0, second=0, tzinfo=timezone.utc).isoformat() - - print(str(start_time)) + print(start_time) + stop_time = (datetime.strptime(query_date, "%Y-%m-%d")).replace(hour=16, minute=0, second=0, tzinfo=timezone.utc).isoformat() + print(stop_time) + # 构建 Flux 查询语句 print("before query influxdb") # 构建 Flux 查询语句 flux_query = f''' from(bucket: "{bucket}") - |> range(start: {start_time}) + |> range(start: {start_time}, stop: {stop_time}) |> filter(fn: (r) => r["_measurement"] == "{measurement}") |> filter(fn: (r) => r["date"] == "{query_date}") |> filter(fn: (r) => r["_field"] == "{property}")