From a0fe7337a739e1fecf85b025a807ff798e37b9be Mon Sep 17 00:00:00 2001 From: William Putra Intan <61998484+williamputraintan@users.noreply.github.com> Date: Mon, 25 Nov 2024 13:34:46 +1100 Subject: [PATCH] Fix(MM): Add reason on history for `add` in m2m relationship (#716) --- .../stacks/metadata-manager/proc/service/load_csv_srv.py | 4 +++- .../metadata-manager/proc/service/tracking_sheet_srv.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/workload/stateless/stacks/metadata-manager/proc/service/load_csv_srv.py b/lib/workload/stateless/stacks/metadata-manager/proc/service/load_csv_srv.py index 4139ca97b..93c338066 100644 --- a/lib/workload/stateless/stacks/metadata-manager/proc/service/load_csv_srv.py +++ b/lib/workload/stateless/stacks/metadata-manager/proc/service/load_csv_srv.py @@ -115,6 +115,7 @@ def load_metadata_csv(df: pd.DataFrame, is_emit_eb_events: bool = True, user_id: try: subject.individual_set.get(orcabus_id=idv.orcabus_id) except ObjectDoesNotExist: + subject._change_reason = reason subject.individual_set.add(idv) # We update the stats when new idv is linked to sbj, only if this is not recorded as @@ -182,6 +183,7 @@ def load_metadata_csv(df: pd.DataFrame, is_emit_eb_events: bool = True, user_id: try: project.contact_set.get(orcabus_id=contact.orcabus_id) except ObjectDoesNotExist: + project._change_reason = reason project.contact_set.add(contact) # We update the stats when new ctc is linked to prj, only if this is not recorded as @@ -236,8 +238,8 @@ def load_metadata_csv(df: pd.DataFrame, is_emit_eb_events: bool = True, user_id: try: library.project_set.get(orcabus_id=project.orcabus_id) except ObjectDoesNotExist: + library._change_reason = reason library.project_set.add(project) - # We update the stats when new project is linked to library, only if this is not recorded as # update/create in previous upsert method if not is_lib_created and not is_lib_updated: diff --git a/lib/workload/stateless/stacks/metadata-manager/proc/service/tracking_sheet_srv.py b/lib/workload/stateless/stacks/metadata-manager/proc/service/tracking_sheet_srv.py index 45728e119..5d6726366 100644 --- a/lib/workload/stateless/stacks/metadata-manager/proc/service/tracking_sheet_srv.py +++ b/lib/workload/stateless/stacks/metadata-manager/proc/service/tracking_sheet_srv.py @@ -137,6 +137,7 @@ def persist_lab_metadata(df: pd.DataFrame, sheet_year: str, is_emit_eb_events: b try: subject.individual_set.get(orcabus_id=idv.orcabus_id) except ObjectDoesNotExist: + subject._change_reason = reason subject.individual_set.add(idv) # We update the stats when new idv is linked to sbj, only if this is not recorded as @@ -192,6 +193,7 @@ def persist_lab_metadata(df: pd.DataFrame, sheet_year: str, is_emit_eb_events: b try: project.contact_set.get(orcabus_id=contact.orcabus_id) except ObjectDoesNotExist: + project._change_reason = reason project.contact_set.add(contact) # We update the stats when new ctc is linked to prj, only if this is not recorded as @@ -247,6 +249,7 @@ def persist_lab_metadata(df: pd.DataFrame, sheet_year: str, is_emit_eb_events: b try: library.project_set.get(orcabus_id=project.orcabus_id) except ObjectDoesNotExist: + library._change_reason = reason library.project_set.add(project) # We update the stats when new project is linked to library, only if this is not recorded as