diff --git a/influxdb_api.py b/influxdb_api.py index df526f8..bdb99be 100644 --- a/influxdb_api.py +++ b/influxdb_api.py @@ -1863,7 +1863,7 @@ def query_all_record_by_date(query_date: str, bucket: str="realtime_simulation_r return node_records, link_records # 2025/03/15 DingZQ -def query_all_records_by_date_with_type(query_date: str, query_type: str, bucket: str="realtime_simulation_result", client: InfluxDBClient=client) -> list: +def query_all_records_by_date_with_type(query_date: str, query_type: str, bucket: str="realtime_simulation_result") -> list: """ 查询指定日期的所有记录,包括‘node’和‘link’,分别以指定的格式返回 :param query_date: 输入的日期,格式为‘2025-02-14’ @@ -1873,13 +1873,10 @@ def query_all_records_by_date_with_type(query_date: str, query_type: str, bucket :return: dict: tuple: (node_records, link_records) """ # 记录开始时间 - time_cost_start = time.perf_counter() - print('{} -- Hydraulic simulation started.'.format( - datetime.now(pytz.timezone('Asia/Shanghai')).strftime('%Y-%m-%d %H:%M:%S'))) + client = get_new_client() - if client.ping(): - pass - else: + time_cost_start = time.perf_counter() + if not client.ping(): print("{} -- Failed to connect to InfluxDB.".format( datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) query_api = client.query_api() @@ -1942,11 +1939,9 @@ def query_all_records_by_date_with_type(query_date: str, query_type: str, bucket "friction": record["friction"] }) time_cost_end = time.perf_counter() - print('{} -- Hydraulic simulation finished, cost time: {:.2f} s.'.format( - datetime.now(pytz.timezone('Asia/Shanghai')).strftime('%Y-%m-%d %H:%M:%S'), - time_cost_end - time_cost_start)) return result_records + # 2025/02/21 def query_all_record_by_date_property(query_date: str, type: str, property: str, bucket: str="realtime_simulation_result") -> list: """