-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add date to messages Add date to notification messages Reviewed-by: Artem Sh.
- Loading branch information
1 parent
4db46c3
commit ae7a1cf
Showing
1 changed file
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
|
||
|
@@ -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="[email protected]", api_key=api_key, site="https://zulip.tsi-vc.otc-service.com") | ||
if row["type"] == "doc": | ||
squad_name = row[3] | ||
|
@@ -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({ | ||
|