From af82b41b08f305dc02b352eb6c39408dff1d8b30 Mon Sep 17 00:00:00 2001 From: Sandeep Rawat Date: Tue, 30 May 2023 12:34:18 +0530 Subject: [PATCH 1/6] Update notification_api.py by adding logger for debugging --- notification/notification_api.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/notification/notification_api.py b/notification/notification_api.py index 6693381..f3a5aff 100644 --- a/notification/notification_api.py +++ b/notification/notification_api.py @@ -78,7 +78,9 @@ def send_mail_to_all_users(): scheme="http", port=config_content.getProperty("elasticsearch.port"), ) - + + logger.info("Connected to ES") + result = es_client.search( index="employee-management", body={ @@ -87,9 +89,12 @@ def send_mail_to_all_users(): } } ) - + logger.info("Fetched results from ES") + for data in result["hits"]["hits"]: send_mail(data["_source"]["email_id"]) + + logger.info("Sent mail") except Exception as e: logger.error("Error while executing elasticsearch query: %s", e) From 5e3b7a0ff76f77f21c94307437cef84c84048908 Mon Sep 17 00:00:00 2001 From: Sandeep Rawat Date: Tue, 30 May 2023 12:38:39 +0530 Subject: [PATCH 2/6] Update notification_api.py for debugging of send_mail --- notification/notification_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notification/notification_api.py b/notification/notification_api.py index f3a5aff..b18c3d7 100644 --- a/notification/notification_api.py +++ b/notification/notification_api.py @@ -43,7 +43,9 @@ def read_configuration(): def send_mail(email_id): """function which will send mail to user""" logger = get_logger() + logger.info("send_mail method called to send email") config_content = read_configuration() + logger.info("Read the configuration file of SMTP connectivity") try: message = emails.html( html="Your salary slip is generated please check", From 2fcbc11f8782134a4960fe9eccac35491c755863 Mon Sep 17 00:00:00 2001 From: Sandeep Rawat Date: Tue, 30 May 2023 12:41:43 +0530 Subject: [PATCH 3/6] Update notification_api.py further debug statements --- notification/notification_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/notification/notification_api.py b/notification/notification_api.py index b18c3d7..57978d3 100644 --- a/notification/notification_api.py +++ b/notification/notification_api.py @@ -94,6 +94,7 @@ def send_mail_to_all_users(): logger.info("Fetched results from ES") for data in result["hits"]["hits"]: + logger.info("Processing one record for email sending") send_mail(data["_source"]["email_id"]) logger.info("Sent mail") From a2e13f254c960d0637e5740804a7687103c0461d Mon Sep 17 00:00:00 2001 From: Sandeep Rawat Date: Tue, 30 May 2023 12:43:28 +0530 Subject: [PATCH 4/6] Update notification_api.py --- notification/notification_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/notification/notification_api.py b/notification/notification_api.py index 57978d3..68dc381 100644 --- a/notification/notification_api.py +++ b/notification/notification_api.py @@ -95,6 +95,7 @@ def send_mail_to_all_users(): for data in result["hits"]["hits"]: logger.info("Processing one record for email sending") + logger.info("Data is %s", data["_source"]["email_id"]) send_mail(data["_source"]["email_id"]) logger.info("Sent mail") From b5367a4657b7e903d8818e4822670eedd49c5715 Mon Sep 17 00:00:00 2001 From: Sandeep Rawat Date: Tue, 30 May 2023 12:45:28 +0530 Subject: [PATCH 5/6] Update notification_api.py --- notification/notification_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notification/notification_api.py b/notification/notification_api.py index 68dc381..2e0834f 100644 --- a/notification/notification_api.py +++ b/notification/notification_api.py @@ -95,7 +95,7 @@ def send_mail_to_all_users(): for data in result["hits"]["hits"]: logger.info("Processing one record for email sending") - logger.info("Data is %s", data["_source"]["email_id"]) + logger.info("Data is %s", str(data)) send_mail(data["_source"]["email_id"]) logger.info("Sent mail") From 6d2b5ac24ec4cb174137649e92dbde10809a9ef8 Mon Sep 17 00:00:00 2001 From: Sandeep Rawat Date: Tue, 30 May 2023 12:47:50 +0530 Subject: [PATCH 6/6] Update notification_api.py --- notification/notification_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notification/notification_api.py b/notification/notification_api.py index 2e0834f..4e819f4 100644 --- a/notification/notification_api.py +++ b/notification/notification_api.py @@ -96,7 +96,7 @@ def send_mail_to_all_users(): for data in result["hits"]["hits"]: logger.info("Processing one record for email sending") logger.info("Data is %s", str(data)) - send_mail(data["_source"]["email_id"]) + send_mail(data["_source"]["email"]) logger.info("Sent mail")