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