Skip to content

Commit 9ffb37c

Browse files
authored
Merge pull request #1200 from NASA-IMPACT/1177-notifications-update-slack-notification-pipeline
1177 notifications update slack notification pipeline
2 parents 9318ab4 + 0d978d7 commit 9ffb37c

File tree

1 file changed

+10
-46
lines changed

1 file changed

+10
-46
lines changed

sde_collections/utils/slack_utils.py

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,95 +4,59 @@
44
from ..models.collection_choice_fields import WorkflowStatusChoices
55

66
SLACK_ID_MAPPING = {
7-
"Carson Davis": "@UESJLQXH6",
8-
"Bishwas Praveen": "@U05QZUF182J",
9-
"Xiang Li": "@U03PPLNDZA7",
10-
"Shravan Vishwanathan": "@U056B4HMGEP",
11-
"Advait Yogaonkar": "@U06L5SKQ5QA",
12-
"Emily Foshee": "@UPKDARB9P",
13-
"Ashish Acharya": "@UC97PNAF6",
14-
"channel": "!here",
7+
"Shravan Vishwanathan": "<@U056B4HMGEP>",
8+
"Advait Yogaonkar": "<@U06L5SKQ5QA>",
9+
"channel": "<!here>",
1510
}
1611

17-
1812
STATUS_CHANGE_NOTIFICATIONS = {
1913
(WorkflowStatusChoices.RESEARCH_IN_PROGRESS, WorkflowStatusChoices.READY_FOR_ENGINEERING): {
2014
"message": "Research on {name} is complete. Ready for engineering! :rocket:",
21-
"tags": [
22-
SLACK_ID_MAPPING["Xiang Li"],
23-
SLACK_ID_MAPPING["Shravan Vishwanathan"],
24-
SLACK_ID_MAPPING["Advait Yogaonkar"],
25-
],
2615
},
2716
(WorkflowStatusChoices.ENGINEERING_IN_PROGRESS, WorkflowStatusChoices.READY_FOR_CURATION): {
2817
"message": "Engineering on {name} is complete. Ready for curation! :mag:",
29-
"tags": [SLACK_ID_MAPPING["Emily Foshee"]],
3018
},
3119
(WorkflowStatusChoices.CURATION_IN_PROGRESS, WorkflowStatusChoices.CURATED): {
3220
"message": "Curation on {name} is complete. It's now curated! :checkered_flag:",
33-
"tags": [
34-
SLACK_ID_MAPPING["Carson Davis"],
35-
SLACK_ID_MAPPING["Bishwas Praveen"],
36-
SLACK_ID_MAPPING["Ashish Acharya"],
37-
],
3821
},
3922
(WorkflowStatusChoices.SECRET_DEPLOYMENT_STARTED, WorkflowStatusChoices.SECRET_DEPLOYMENT_FAILED): {
4023
"message": "Alert: Secret deployment of {name} has failed! :warning:",
41-
"tags": [
42-
SLACK_ID_MAPPING["Carson Davis"],
43-
SLACK_ID_MAPPING["Bishwas Praveen"],
44-
SLACK_ID_MAPPING["Ashish Acharya"],
45-
],
4624
},
4725
(WorkflowStatusChoices.SECRET_DEPLOYMENT_STARTED, WorkflowStatusChoices.READY_FOR_LRM_QUALITY_CHECK): {
4826
"message": "Indexing of {name} on Secret Prod completed successfully. Ready for LRM QC! :clipboard:",
49-
"tags": [SLACK_ID_MAPPING["Shravan Vishwanathan"], SLACK_ID_MAPPING["Advait Yogaonkar"]],
5027
},
5128
(WorkflowStatusChoices.READY_FOR_LRM_QUALITY_CHECK, WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK): {
5229
"message": "LRM QC passed for {name}. Ready for final quality check! :white_check_mark:",
53-
"tags": [SLACK_ID_MAPPING["Emily Foshee"]],
5430
},
5531
(WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_FAILED): {
5632
"message": "Quality check on {name} has failed. Changes needed! :x:",
57-
"tags": [
58-
SLACK_ID_MAPPING["Xiang Li"],
59-
SLACK_ID_MAPPING["Shravan Vishwanathan"],
60-
SLACK_ID_MAPPING["Advait Yogaonkar"],
61-
],
33+
"mention_users": ["Shravan Vishwanathan", "Advait Yogaonkar"],
6234
},
6335
(WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_PERFECT): {
6436
"message": "{name} has passed all quality checks and is ready for public production! :white_check_mark:",
65-
"tags": [
66-
SLACK_ID_MAPPING["Carson Davis"],
67-
SLACK_ID_MAPPING["Bishwas Praveen"],
68-
SLACK_ID_MAPPING["Ashish Acharya"],
69-
],
7037
},
7138
(WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_MINOR): {
7239
"message": "{name} has passed all quality checks and is ready for public production! :white_check_mark:",
73-
"tags": [
74-
SLACK_ID_MAPPING["Carson Davis"],
75-
SLACK_ID_MAPPING["Bishwas Praveen"],
76-
SLACK_ID_MAPPING["Ashish Acharya"],
77-
],
7840
},
7941
(WorkflowStatusChoices.QUALITY_CHECK_PERFECT, WorkflowStatusChoices.PROD_PERFECT): {
8042
"message": "{name} is now live on Public Prod! Congrats team! :sparkles:",
81-
"tags": [SLACK_ID_MAPPING["channel"]],
43+
"mention_users": ["channel"],
8244
},
8345
(WorkflowStatusChoices.QUALITY_CHECK_MINOR, WorkflowStatusChoices.PROD_MINOR): {
8446
"message": "{name} is now live on Public Prod! Congrats team! :sparkles:",
85-
"tags": [SLACK_ID_MAPPING["channel"]],
47+
"mention_users": ["channel"],
8648
},
8749
}
8850

8951

9052
def format_slack_message(name, details, collection_id):
9153
message_template = details["message"]
92-
tags = " ".join([f"<{user}>" for user in details["tags"]])
9354
link = f"https://sde-indexing-helper.nasa-impact.net/{collection_id}/" # noqa: E231
9455
linked_name = f"<{link}|{name}>"
95-
return tags + " " + message_template.format(name=linked_name)
56+
if "mention_users" in details:
57+
slack_mentions = " ".join(SLACK_ID_MAPPING[user] for user in details["mention_users"])
58+
return slack_mentions + " " + message_template.format(name=linked_name)
59+
return message_template.format(name=linked_name)
9660

9761

9862
def send_slack_message(message):

0 commit comments

Comments
 (0)