Refine time
This commit is contained in:
@@ -2600,12 +2600,15 @@ def query_scheme_all_record(scheme_Type: str, scheme_Name: str, query_date: str,
|
|||||||
print("{} -- Failed to connect to InfluxDB.".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
print("{} -- Failed to connect to InfluxDB.".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||||
|
|
||||||
query_api = client.query_api()
|
query_api = client.query_api()
|
||||||
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 = datetime.strptime(query_date, "%Y-%m-%d").replace(hour=15, minute=59, second=59, tzinfo=timezone.utc).isoformat()
|
bg_start_time, bg_end_time = time_api.parse_beijing_date_range(query_date=query_date)
|
||||||
|
utc_start_time = time_api.to_utc_time(bg_start_time)
|
||||||
|
utc_stop_time = time_api.to_utc_time(bg_end_time)
|
||||||
|
|
||||||
# 构建 Flux 查询语句
|
# 构建 Flux 查询语句
|
||||||
flux_query = f'''
|
flux_query = f'''
|
||||||
from(bucket: "{bucket}")
|
from(bucket: "{bucket}")
|
||||||
|> range(start: {start_time}, stop: {stop_time})
|
|> range(start: {utc_start_time.isoformat()}, stop: {utc_stop_time.isoformat()})
|
||||||
|> filter(fn: (r) => r["scheme_Type"] == "{scheme_Type}" and r["scheme_Name"] == "{scheme_Name}" and r["_measurement"] == "node" or r["_measurement"] == "link")
|
|> filter(fn: (r) => r["scheme_Type"] == "{scheme_Type}" and r["scheme_Name"] == "{scheme_Name}" and r["_measurement"] == "node" or r["_measurement"] == "link")
|
||||||
|> pivot(
|
|> pivot(
|
||||||
rowKey:["_time"],
|
rowKey:["_time"],
|
||||||
|
|||||||
Reference in New Issue
Block a user