From a94d0144eab977795267210ae01dbc385c58439d Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:50:59 +0800 Subject: [PATCH] Fix: Don't relay on validator when creating StoredPlannerProxy objects --- tasks/planner/model.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tasks/planner/model.py b/tasks/planner/model.py index 53cbe820a..098253f7f 100644 --- a/tasks/planner/model.py +++ b/tasks/planner/model.py @@ -118,23 +118,30 @@ class StoredPlannerProxy(BaseModelWithFallback): def val_value(self): if self.item.has_group_base: if not isinstance(self.value, MultiValue): - logger.warning(f'Planner item {self.item} has_group_base but given `value` is not a MultiValue') + logger.warning(f'Planner item {self.item} has_group_base ' + f'but given value={self.value} is not a MultiValue') self.value = MultiValue() if not isinstance(self.total, MultiValue): - logger.warning(f'Planner item {self.item} has_group_base but given `total` is not a MultiValue') + logger.warning(f'Planner item {self.item} has_group_base ' + f'but given total={self.total} is not a MultiValue') self.total = MultiValue() + raise Exception if not isinstance(self.synthesize, MultiValue): - logger.warning(f'Planner item {self.item} has_group_base but given `synthesize` is not a MultiValue') + logger.warning(f'Planner item {self.item} has_group_base ' + f'but given synthesize={self.synthesize} is not a MultiValue') self.synthesize = MultiValue() else: if not isinstance(self.value, int): - logger.warning(f'Planner item {self.item} has no group base but given `value` is not an int') + logger.warning(f'Planner item {self.item} has no group base ' + f'but given value={self.value} is not an int') self.value = 0 if not isinstance(self.total, int): - logger.warning(f'Planner item {self.item} has no group base but given `total` is not an int') + logger.warning(f'Planner item {self.item} has no group base ' + f'but given total={self.total} is not an int') self.total = 0 if not isinstance(self.synthesize, int): - logger.warning(f'Planner item {self.item} has no group base but given `synthesize` is not an int') + logger.warning(f'Planner item {self.item} has no group base ' + f'but given synthesize={self.synthesize} is not an int') self.synthesize = 0 return self @@ -424,7 +431,11 @@ class PlannerProgressParser: base = row.item.group_base if base.name not in self.rows: try: - obj = StoredPlannerProxy(item=base) + if row.item.has_group_base: + obj = StoredPlannerProxy( + item=base, value=MultiValue(), total=MultiValue(), synthesize=MultiValue()) + else: + obj = StoredPlannerProxy(item=base, value=0, total=0, synthesize=0) except ScriptError as e: logger.error(e) continue