修复数据索引类型错误
This commit is contained in:
@@ -13,6 +13,6 @@ if __name__ == "__main__":
|
|||||||
"main:app",
|
"main:app",
|
||||||
host="0.0.0.0",
|
host="0.0.0.0",
|
||||||
port=8000,
|
port=8000,
|
||||||
# workers=2, # 这里可以设置多进程
|
workers=2, # 这里可以设置多进程
|
||||||
loop="asyncio",
|
loop="asyncio",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -160,7 +160,9 @@ class SchemeRepository:
|
|||||||
query, (scheme_type, scheme_name, start_time, end_time, link_id)
|
query, (scheme_type, scheme_name, start_time, end_time, link_id)
|
||||||
)
|
)
|
||||||
rows = await cur.fetchall()
|
rows = await cur.fetchall()
|
||||||
return [{"time": row["time"].isoformat(), "value": row[field]} for row in rows]
|
return [
|
||||||
|
{"time": row["time"].isoformat(), "value": row[field]} for row in rows
|
||||||
|
]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_links_field_by_scheme_and_time_range(
|
async def get_links_field_by_scheme_and_time_range(
|
||||||
@@ -194,10 +196,9 @@ class SchemeRepository:
|
|||||||
rows = await cur.fetchall()
|
rows = await cur.fetchall()
|
||||||
result = defaultdict(list)
|
result = defaultdict(list)
|
||||||
for row in rows:
|
for row in rows:
|
||||||
result[row["id"]].append({
|
result[row["id"]].append(
|
||||||
"time": row["time"].isoformat(),
|
{"time": row["time"].isoformat(), "value": row[field]}
|
||||||
"value": row[field]
|
)
|
||||||
})
|
|
||||||
return dict(result)
|
return dict(result)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -375,7 +376,9 @@ class SchemeRepository:
|
|||||||
query, (scheme_type, scheme_name, start_time, end_time, node_id)
|
query, (scheme_type, scheme_name, start_time, end_time, node_id)
|
||||||
)
|
)
|
||||||
rows = await cur.fetchall()
|
rows = await cur.fetchall()
|
||||||
return [{"time": row["time"].isoformat(), "value": row[field]} for row in rows]
|
return [
|
||||||
|
{"time": row["time"].isoformat(), "value": row[field]} for row in rows
|
||||||
|
]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_nodes_field_by_scheme_and_time_range(
|
async def get_nodes_field_by_scheme_and_time_range(
|
||||||
@@ -400,10 +403,9 @@ class SchemeRepository:
|
|||||||
rows = await cur.fetchall()
|
rows = await cur.fetchall()
|
||||||
result = defaultdict(list)
|
result = defaultdict(list)
|
||||||
for row in rows:
|
for row in rows:
|
||||||
result[row["id"]].append({
|
result[row["id"]].append(
|
||||||
"time": row["time"].isoformat(),
|
{"time": row["time"].isoformat(), "value": row[field]}
|
||||||
"value": row[field]
|
)
|
||||||
})
|
|
||||||
return dict(result)
|
return dict(result)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -695,7 +697,12 @@ class SchemeRepository:
|
|||||||
raise ValueError(f"Invalid type: {type}. Must be 'node' or 'link'")
|
raise ValueError(f"Invalid type: {type}. Must be 'node' or 'link'")
|
||||||
|
|
||||||
# Format the results
|
# Format the results
|
||||||
return [{"ID": item["id"], "value": item["value"]} for item in data]
|
# Format the results
|
||||||
|
result = []
|
||||||
|
for id, items in data.items():
|
||||||
|
for item in items:
|
||||||
|
result.append({"ID": id, "value": item["value"]})
|
||||||
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def query_scheme_simulation_result_by_id_time(
|
async def query_scheme_simulation_result_by_id_time(
|
||||||
|
|||||||
Reference in New Issue
Block a user