From: Christian Heller Date: Tue, 24 Dec 2024 08:09:01 +0000 (+0100) Subject: Restore explicit ProcessStep node siblings replacing implicit ones. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/templates?a=commitdiff_plain;h=211eff47c2dc4086fd09ce0cec83cd79e60da118;p=plomtask Restore explicit ProcessStep node siblings replacing implicit ones. --- diff --git a/plomtask/processes.py b/plomtask/processes.py index 3c8eebe..ff45932 100644 --- a/plomtask/processes.py +++ b/plomtask/processes.py @@ -92,18 +92,22 @@ class Process(BaseModel[int], ConditionsRelations): owner_ids.add(id_) return [self.__class__.by_id(db_conn, id_) for id_ in owner_ids] - def get_steps(self, db_conn: DatabaseConnection, external_owner: - Process | None = None) -> list[ProcessStepsNode]: + def get_steps(self, + db_conn: DatabaseConnection, + external_owner: Process | None = None + ) -> list[ProcessStepsNode]: """Return tree of depended-on explicit and implicit ProcessSteps.""" def make_node(step: ProcessStep, suppressed: bool) -> ProcessStepsNode: - is_explicit = False - if external_owner is not None: - is_explicit = step.owner_id == external_owner.id_ + is_explicit = step.owner_id == top_owner.id_ process = self.__class__.by_id(db_conn, step.step_process_id) step_steps = [] if not suppressed: - step_steps = process.get_steps(db_conn, external_owner) + # exclude implicit siblings to explicit steps of same process + step_steps = [n for n in process.get_steps(db_conn, top_owner) + if not [s for s in top_owner.explicit_steps + if s.parent_step_id == step.id_ + and s.step_process_id == n.process.id_]] return ProcessStepsNode(step, process, is_explicit, step_steps, False, suppressed) @@ -122,12 +126,11 @@ class Process(BaseModel[int], ConditionsRelations): step_nodes: list[ProcessStepsNode] = [] seen_step_ids: Set[int] = set() - if external_owner is None: - external_owner = self + top_owner = external_owner or self for step in [s for s in self.explicit_steps if s.parent_step_id is None]: assert isinstance(step.id_, int) - new_node = make_node(step, step in external_owner.suppressed_steps) + new_node = make_node(step, step in top_owner.suppressed_steps) step_nodes += [new_node] for step_node in step_nodes: walk_steps(step_node)