Code refactor for change set
This commit is contained in:
@@ -22,7 +22,7 @@ def get_reaction(name: str) -> dict[str, Any]:
|
||||
return d
|
||||
|
||||
|
||||
def set_reaction_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
def set_reaction_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
raw_old = get_reaction(name)
|
||||
|
||||
old = {}
|
||||
@@ -53,7 +53,7 @@ def set_reaction_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
undo_sql += f"update reactions set value = '{value}' where key = '{key}';"
|
||||
undo_cs |= { key: value }
|
||||
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
return DbChangeSet(redo_sql, undo_sql, [redo_cs], [undo_cs])
|
||||
|
||||
|
||||
def set_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
@@ -92,7 +92,7 @@ class PipeReaction(object):
|
||||
return { 'type': self.type, 'pipe': self.pipe, 'bulk': self.bulk, 'wall': self.wall }
|
||||
|
||||
|
||||
def set_pipe_reaction_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
def set_pipe_reaction_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
old = PipeReaction(get_pipe_reaction(name, cs.operations[0]['pipe']))
|
||||
raw_new = get_pipe_reaction(name, cs.operations[0]['pipe'])
|
||||
|
||||
@@ -118,7 +118,7 @@ def set_pipe_reaction_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
redo_cs = g_update_prefix | new.as_dict()
|
||||
undo_cs = g_update_prefix | old.as_dict()
|
||||
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
return DbChangeSet(redo_sql, undo_sql, [redo_cs], [undo_cs])
|
||||
|
||||
|
||||
def set_pipe_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
@@ -152,7 +152,7 @@ class TankReaction(object):
|
||||
return { 'type': self.type, 'tank': self.tank, 'value': self.value }
|
||||
|
||||
|
||||
def set_tank_reaction_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
def set_tank_reaction_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
old = TankReaction(get_tank_reaction(name, cs.operations[0]['tank']))
|
||||
raw_new = get_tank_reaction(name, cs.operations[0]['tank'])
|
||||
|
||||
@@ -174,7 +174,7 @@ def set_tank_reaction_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
redo_cs = g_update_prefix | new.as_dict()
|
||||
undo_cs = g_update_prefix | old.as_dict()
|
||||
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
return DbChangeSet(redo_sql, undo_sql, [redo_cs], [undo_cs])
|
||||
|
||||
|
||||
def set_tank_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
Reference in New Issue
Block a user