From a1b8fc3e78ed884e11329bd8dbf6d83dbf3a75fc Mon Sep 17 00:00:00 2001 From: sweng66 Date: Thu, 12 Dec 2024 16:41:55 -0800 Subject: [PATCH 1/2] adding a new field 'updated_by_email' to WFT show endpoint --- agr_literature_service/api/crud/workflow_tag_crud.py | 10 ++++++++++ .../api/schemas/workflow_tag_schemas.py | 1 + 2 files changed, 11 insertions(+) diff --git a/agr_literature_service/api/crud/workflow_tag_crud.py b/agr_literature_service/api/crud/workflow_tag_crud.py index 77c502175..c5f303143 100644 --- a/agr_literature_service/api/crud/workflow_tag_crud.py +++ b/agr_literature_service/api/crud/workflow_tag_crud.py @@ -545,6 +545,16 @@ def show(db: Session, reference_workflow_tag_id: int): else: workflow_tag_data["mod_abbreviation"] = "" del workflow_tag_data["mod_id"] + ## add email address for updated_by + sql_query_str = """ + SELECT email + FROM users + WHERE id = :okta_id + """ + sql_query = text(sql_query_str) + result = db.execute(sql_query, {'okta_id': workflow_tag_data["updated_by"]}) + row = result.fetchone() + workflow_tag_data["updated_by_email"] = workflow_tag_data["updated_by"] if row is None else row[0] return workflow_tag_data diff --git a/agr_literature_service/api/schemas/workflow_tag_schemas.py b/agr_literature_service/api/schemas/workflow_tag_schemas.py index 26076b648..a861d7236 100644 --- a/agr_literature_service/api/schemas/workflow_tag_schemas.py +++ b/agr_literature_service/api/schemas/workflow_tag_schemas.py @@ -19,6 +19,7 @@ class WorkflowTagSchemaRelated(AuditedObjectModelSchema): reference_workflow_tag_id: Optional[int] workflow_tag_id: str mod_abbreviation: Optional[str] + updated_by_email: str # used by workflow_tag_crud From 99fc2f0edfbb6698310ef029817570ce3ab14fd9 Mon Sep 17 00:00:00 2001 From: sweng66 Date: Fri, 13 Dec 2024 12:54:06 -0800 Subject: [PATCH 2/2] changing updated_by_email field to optional --- agr_literature_service/api/schemas/workflow_tag_schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agr_literature_service/api/schemas/workflow_tag_schemas.py b/agr_literature_service/api/schemas/workflow_tag_schemas.py index a861d7236..169af4123 100644 --- a/agr_literature_service/api/schemas/workflow_tag_schemas.py +++ b/agr_literature_service/api/schemas/workflow_tag_schemas.py @@ -19,7 +19,7 @@ class WorkflowTagSchemaRelated(AuditedObjectModelSchema): reference_workflow_tag_id: Optional[int] workflow_tag_id: str mod_abbreviation: Optional[str] - updated_by_email: str + updated_by_email: Optional[str] # used by workflow_tag_crud