Refine api to support one batch command
This commit is contained in:
@@ -20,8 +20,8 @@ def get_demand(name: str, junction: str) -> dict[str, Any]:
|
||||
ds.append(d)
|
||||
return { 'junction': junction, 'demands': ds }
|
||||
|
||||
# { 'operation': 'update', 'type': 'demand', 'junction': 'j1', 'demands': [{'demand': 0.0, 'patten': None, 'category': None}] }
|
||||
def set_demand(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
def set_demand_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
junction = cs.operations[0]['junction']
|
||||
old = get_demand(name, junction)
|
||||
new = { 'junction': junction, 'demands': [] }
|
||||
@@ -53,4 +53,8 @@ def set_demand(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
redo_cs = g_update_prefix | { 'type': 'demand' } | new
|
||||
undo_cs = g_update_prefix | { 'type': 'demand' } | old
|
||||
|
||||
return execute_command(name, redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
|
||||
|
||||
def set_demand(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_demand_cache(name, cs))
|
||||
|
||||
Reference in New Issue
Block a user