From b6e77ce508c3863eddf00e5b6c6befbc81a7a738 Mon Sep 17 00:00:00 2001 From: "sandipsamal117@gmail.com" Date: Sun, 28 Jan 2024 19:53:12 -0500 Subject: [PATCH] fix datetime for existing records --- app/config.py | 2 +- app/controllers/subprocesses/utils.py | 2 +- app/controllers/workflow.py | 5 +++-- app/models/workflow.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/config.py b/app/config.py index 4b1c81a..9b3fcd3 100644 --- a/app/config.py +++ b/app/config.py @@ -3,7 +3,7 @@ class Settings(BaseSettings): pflink_mongodb: MongoDsn = 'mongodb://localhost:27017' - version: str = "3.8.4" + version: str = "3.8.5" mongo_username: str = "admin" mongo_password: str = "admin" log_level: str = "DEBUG" diff --git a/app/controllers/subprocesses/utils.py b/app/controllers/subprocesses/utils.py index 379f0ac..ff5babc 100644 --- a/app/controllers/subprocesses/utils.py +++ b/app/controllers/subprocesses/utils.py @@ -42,7 +42,7 @@ def workflow_retrieve_helper(workflow: dict) -> WorkflowDBSchema: return WorkflowDBSchema( key=workflow["_id"], fingerprint=workflow["fingerprint"], - creation_time=datetime.min.strftime("%Y-%m-%d %H:%M:%S") if not workflow.get("creation_time") else workflow["creation_time"], + creation_time=datetime.min.strftime("%Y-%m-%d %H:%M:%S") if not workflow.get("creation_time") else str(workflow["creation_time"]), request=request, response=workflow["response"], service_retry=workflow["service_retry"], diff --git a/app/controllers/workflow.py b/app/controllers/workflow.py index bfca9f5..20c9c34 100644 --- a/app/controllers/workflow.py +++ b/app/controllers/workflow.py @@ -1,4 +1,4 @@ -import datetime +from datetime import datetime from pymongo import MongoClient, TEXT import json @@ -148,8 +148,9 @@ def create_new_workflow( test: bool = False, ) -> WorkflowDBSchema: """Create a new workflow object and add it to the database""" + creation_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") response = WorkflowStatusResponseSchema() - new_workflow = WorkflowDBSchema(key=key, fingerprint=fingerprint, request=request, response=response) + new_workflow = WorkflowDBSchema(key=key, fingerprint=fingerprint, creation_time=creation_time, request=request, response=response) workflow = add_workflow(new_workflow, test) pretty_response = pprint.pformat(workflow.response.__dict__) logger.info(f"New workflow record created.", extra=d) diff --git a/app/models/workflow.py b/app/models/workflow.py index e54e95d..3055e72 100644 --- a/app/models/workflow.py +++ b/app/models/workflow.py @@ -158,7 +158,7 @@ class WorkflowDBSchema(BaseModel): """The DB model of a workflow object""" key: str = "" fingerprint: str = "" - creation_time: str = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + creation_time: str = "" request: WorkflowRequestSchema response: WorkflowStatusResponseSchema service_retry: int = 5