Skip to content

Commit

Permalink
add date to messages (#53)
Browse files Browse the repository at this point in the history
Add date to messages

Add date to notification messages

Reviewed-by: Artem Sh.
  • Loading branch information
YustinaKvr committed Feb 29, 2024
1 parent 4db46c3 commit ae7a1cf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
from psycopg2.extras import DictCursor
import zulip
from datetime import datetime

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

Expand Down Expand Up @@ -117,6 +118,7 @@ def check_outdated_docs(conn, squad_name, stream_name, topic_name):


def send_zulip_notification(row, api_key, stream_name, topic_name):
current_date = datetime.now().strftime("%Y-%m-%d")
client = zulip.Client(email="apimon-bot@zulip.tsi-dev.otc-service.com", api_key=api_key, site="https://zulip.tsi-vc.otc-service.com")
if row["type"] == "doc":
squad_name = row[3]
Expand All @@ -140,22 +142,22 @@ def send_zulip_notification(row, api_key, stream_name, topic_name):
else:
return

message += f"\n\n**Squad name:** {squad_name}\n**Service name:** {service_name}\n**Zone:** {row[-2]}\n\n**Commit" \
message += f"\n\n**Squad name:** {squad_name}\n**Service name:** {service_name}\n**Zone:** {row[-2]}\n**Date:** {current_date}\n\n**Commit" \
f" URL:** {commit_url}\n**Dashboard URL:** https://dashboard.tsi-dev.otc-service.com/d/c67f0f4b-b31c-" \
f"4433-b530-a18896470d49/last-docs-commit?orgId=1\n\n---------------------------------------------------------"
elif row["type"] == "issue":
squad_name = row[3]
service_name = row[2]
issue_url = row[5]
message = f":point_right: **Unattended Issues Alert** :point_left:\n\nYou have an issue which has no assignees for more than 7 days\n\n" \
f"**Squad name:** {squad_name}\n**Service name:** {service_name}\n**Zone:** {row[-2]}\n\n**Issue URL:" \
f"**Squad name:** {squad_name}\n**Service name:** {service_name}\n**Zone:** {row[-2]}\n**Date:** {current_date}\n\n**Issue URL:" \
f"** {issue_url}\n**Dashboard URL:** https://dashboard.tsi-dev.otc-service.com/d/I-YJAuBVk/open-issues" \
f"-dashboard?orgId=1&var-squad_issues=All&var-env_issues=All&var-sort_duration=DESC&var-zone=open_issues\n\n---------------------------------------------------------"
elif row["type"] == "orphan":
squad_name = row[3]
service_name = row[2]
orphan_url = row[4]
message = f":boom: **Orphaned PRs Alert** :boom:\n\nYou have orphaned PR here!\n\n**Squad name:** {squad_name}\n**Service name:** {service_name}\n**Zone:** {row[-2]}\n\n" \
message = f":boom: **Orphaned PRs Alert** :boom:\n\nYou have orphaned PR here!\n\n**Squad name:** {squad_name}\n**Service name:** {service_name}\n**Zone:** {row[-2]}\n**Date:** {current_date}\n\n" \
f"**Orphan URL:** {orphan_url}\n**Dashboard URL:** https://dashboard.tsi-dev.otc-service.com/d/4vLGLDB" \
f"4z/open-prs-dashboard?orgId=1\n\n---------------------------------------------------------"
result = client.send_message({
Expand Down

0 comments on commit ae7a1cf

Please sign in to comment.