Update setdemand

This commit is contained in:
DingZQ
2022-11-12 16:24:12 +08:00
parent 94f5fae812
commit d54ce2df71

View File

@@ -869,14 +869,14 @@ async def fast_get_demand_schema(network: str) -> dict[str, dict[str, Any]]:
return get_demand_schema(network)
@app.get("/getdemandproperties/")
async def fastapi_get_demand_properties(network: str, demand: str) -> dict[str, Any]:
return get_demand(network, demand)
async def fastapi_get_demand_properties(network: str, junction: str) -> dict[str, Any]:
return get_demand(network, junction)
# example: set_demand(p, ChangeSet({'junction': 'j1', 'demands': [{'demand': 10.0, 'pattern': None, 'category': 'x'}, {'demand': 20.0, 'pattern': None, 'category': None}]}))
@app.post("/setdemandproperties/")
async def fastapi_set_demand_properties(network: str, demand: str, req: Request) -> ChangeSet:
async def fastapi_set_demand_properties(network: str, junction: str, req: Request) -> ChangeSet:
props = await req.json()
ps = { 'id' : demand } | props
ps = { 'junction' : junction } | props
return set_demand(network, ChangeSet(ps))
############################################################