Refine
This commit is contained in:
21
main.py
21
main.py
@@ -2147,6 +2147,27 @@ async def fastapi_query_all_records_by_date(querydate: str) -> dict[str, list]:
|
||||
return { "nodes": results[0],
|
||||
"links": results[1] }
|
||||
|
||||
#2025-03-15, DingZQ
|
||||
@app.get("/queryallrecordsbydatewithtype/")
|
||||
async def fastapi_query_all_records_by_date_with_type(querydate: str, querytype: str) -> list:
|
||||
# 缓存查询结果提高性能
|
||||
global redis_client
|
||||
cache_key = f"queryallrecordsbydatewithtype_{querydate}_{querytype}"
|
||||
data = redis_client.get(cache_key)
|
||||
if data:
|
||||
# 使用自定义的反序列化函数
|
||||
loaded_dict = msgpack.unpackb(data, object_hook=object_hook)
|
||||
return loaded_dict
|
||||
|
||||
results = influxdb_api.query_all_records_by_date_with_type(query_date=querydate, query_type=querytype, client=influx_client)
|
||||
packed = msgpack.packb(result_dict, default=default_encoder)
|
||||
redis_client.set(cache_key, packed)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
|
||||
|
||||
# 查询指定日期、类型、属性的所有记录
|
||||
# 返回 [{'time': '2024-01-01T00:00:00Z', 'ID': '1', 'value': 1.0}, {'time': '2024-01-01T00:00:00Z', 'ID': '2', 'value': 2.0}]
|
||||
@app.get("/queryallrecordsbydateproperty/")
|
||||
|
||||
Reference in New Issue
Block a user