|
4 | 4 | from ..models.collection_choice_fields import WorkflowStatusChoices
|
5 | 5 |
|
6 | 6 | 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>", |
15 | 10 | }
|
16 | 11 |
|
17 |
| - |
18 | 12 | STATUS_CHANGE_NOTIFICATIONS = {
|
19 | 13 | (WorkflowStatusChoices.RESEARCH_IN_PROGRESS, WorkflowStatusChoices.READY_FOR_ENGINEERING): {
|
20 | 14 | "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 |
| - ], |
26 | 15 | },
|
27 | 16 | (WorkflowStatusChoices.ENGINEERING_IN_PROGRESS, WorkflowStatusChoices.READY_FOR_CURATION): {
|
28 | 17 | "message": "Engineering on {name} is complete. Ready for curation! :mag:",
|
29 |
| - "tags": [SLACK_ID_MAPPING["Emily Foshee"]], |
30 | 18 | },
|
31 | 19 | (WorkflowStatusChoices.CURATION_IN_PROGRESS, WorkflowStatusChoices.CURATED): {
|
32 | 20 | "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 |
| - ], |
38 | 21 | },
|
39 | 22 | (WorkflowStatusChoices.SECRET_DEPLOYMENT_STARTED, WorkflowStatusChoices.SECRET_DEPLOYMENT_FAILED): {
|
40 | 23 | "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 |
| - ], |
46 | 24 | },
|
47 | 25 | (WorkflowStatusChoices.SECRET_DEPLOYMENT_STARTED, WorkflowStatusChoices.READY_FOR_LRM_QUALITY_CHECK): {
|
48 | 26 | "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"]], |
50 | 27 | },
|
51 | 28 | (WorkflowStatusChoices.READY_FOR_LRM_QUALITY_CHECK, WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK): {
|
52 | 29 | "message": "LRM QC passed for {name}. Ready for final quality check! :white_check_mark:",
|
53 |
| - "tags": [SLACK_ID_MAPPING["Emily Foshee"]], |
54 | 30 | },
|
55 | 31 | (WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_FAILED): {
|
56 | 32 | "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"], |
62 | 34 | },
|
63 | 35 | (WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_PERFECT): {
|
64 | 36 | "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 |
| - ], |
70 | 37 | },
|
71 | 38 | (WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_MINOR): {
|
72 | 39 | "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 |
| - ], |
78 | 40 | },
|
79 | 41 | (WorkflowStatusChoices.QUALITY_CHECK_PERFECT, WorkflowStatusChoices.PROD_PERFECT): {
|
80 | 42 | "message": "{name} is now live on Public Prod! Congrats team! :sparkles:",
|
81 |
| - "tags": [SLACK_ID_MAPPING["channel"]], |
| 43 | + "mention_users": ["channel"], |
82 | 44 | },
|
83 | 45 | (WorkflowStatusChoices.QUALITY_CHECK_MINOR, WorkflowStatusChoices.PROD_MINOR): {
|
84 | 46 | "message": "{name} is now live on Public Prod! Congrats team! :sparkles:",
|
85 |
| - "tags": [SLACK_ID_MAPPING["channel"]], |
| 47 | + "mention_users": ["channel"], |
86 | 48 | },
|
87 | 49 | }
|
88 | 50 |
|
89 | 51 |
|
90 | 52 | def format_slack_message(name, details, collection_id):
|
91 | 53 | message_template = details["message"]
|
92 |
| - tags = " ".join([f"<{user}>" for user in details["tags"]]) |
93 | 54 | link = f"https://sde-indexing-helper.nasa-impact.net/{collection_id}/" # noqa: E231
|
94 | 55 | 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) |
96 | 60 |
|
97 | 61 |
|
98 | 62 | def send_slack_message(message):
|
|
0 commit comments