Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved the issue of sending mail due to invalid column name #14

Open
wants to merge 6 commits into
base: salary-update
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions notification/notification_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="<strong>Your salary slip is generated please check</strong>",
Expand Down Expand Up @@ -78,7 +80,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={
Expand All @@ -87,9 +91,14 @@ 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("Processing one record for email sending")
logger.info("Data is %s", str(data))
send_mail(data["_source"]["email"])

logger.info("Sent mail")

except Exception as e:
logger.error("Error while executing elasticsearch query: %s", e)
Expand Down