Refine
This commit is contained in:
@@ -1344,6 +1344,7 @@ def query_all_record_by_date(query_date: str, bucket: str="realtime_simulation_r
|
||||
:param client: 已初始化的InfluxDBClient 实例。
|
||||
:return: dict: tuple: (node_records, link_records)
|
||||
"""
|
||||
|
||||
if client.ping():
|
||||
print("{} -- Successfully connected to InfluxDB.".format(
|
||||
datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||
@@ -1351,10 +1352,12 @@ def query_all_record_by_date(query_date: str, bucket: str="realtime_simulation_r
|
||||
print("{} -- Failed to connect to InfluxDB.".format(
|
||||
datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||
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()
|
||||
# 构建 Flux 查询语句
|
||||
flux_query = f'''
|
||||
from(bucket: "{bucket}")
|
||||
|> range(start: 2025-01-01T00:00:00Z)
|
||||
|> range(start: {start_time})
|
||||
|> filter(fn: (r) => r["_measurement"] == "node" or r["_measurement"] == "link")
|
||||
|> filter(fn: (r) => r["date"] == "{query_date}")
|
||||
|> pivot(
|
||||
@@ -1363,6 +1366,7 @@ def query_all_record_by_date(query_date: str, bucket: str="realtime_simulation_r
|
||||
valueColumn:"_value"
|
||||
)
|
||||
'''
|
||||
|
||||
# 执行查询
|
||||
tables = query_api.query(flux_query)
|
||||
node_records = []
|
||||
|
||||
Reference in New Issue
Block a user