From 6490e23815544b771c29e5ad2b7540f264fd4d11 Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Mon, 8 Jul 2024 13:03:33 -0400 Subject: [PATCH] fixed PR comments --- pepdbagent/db_utils.py | 2 +- pepdbagent/modules/project.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pepdbagent/db_utils.py b/pepdbagent/db_utils.py index 378c303..ea36bd8 100644 --- a/pepdbagent/db_utils.py +++ b/pepdbagent/db_utils.py @@ -264,7 +264,7 @@ class HistoryProjects(Base): project_mapping: Mapped["Projects"] = relationship( "Projects", back_populates="history_mapping" - ) # TODO: check if cascade is correct + ) sample_changes_mapping: Mapped[List["HistorySamples"]] = relationship( back_populates="history_project_mapping", cascade="all, delete-orphan" ) diff --git a/pepdbagent/modules/project.py b/pepdbagent/modules/project.py index c99e1f5..1e63992 100644 --- a/pepdbagent/modules/project.py +++ b/pepdbagent/modules/project.py @@ -1235,11 +1235,11 @@ def get_project_from_history( ) @staticmethod - def _apply_history_changes(sample_list: dict, change: HistoryProjects) -> dict: + def _apply_history_changes(sample_dict: dict, change: HistoryProjects) -> dict: """ Apply changes from the history to the sample list - :param sample_list: dictionary with samples + :param sample_dict: dictionary with samples :param change: history change :return: updated sample list """ @@ -1247,20 +1247,20 @@ def _apply_history_changes(sample_list: dict, change: HistoryProjects) -> dict: sample_id = sample_change.guid if sample_change.change_type == UpdateTypes.UPDATE: - sample_list[sample_id]["sample"] = sample_change.sample_json - sample_list[sample_id]["parent_guid"] = sample_change.parent_guid + sample_dict[sample_id]["sample"] = sample_change.sample_json + sample_dict[sample_id]["parent_guid"] = sample_change.parent_guid elif sample_change.change_type == UpdateTypes.DELETE: - sample_list[sample_id] = { + sample_dict[sample_id] = { "sample": sample_change.sample_json, "guid": sample_id, "parent_guid": sample_change.parent_guid, } elif sample_change.change_type == UpdateTypes.INSERT: - del sample_list[sample_id] + del sample_dict[sample_id] - return sample_list + return sample_dict def delete_history( self, namespace: str, name: str, tag: str, history_id: Union[int, None] = None