Skip to content

Commit

Permalink
Merge pull request #4334 from ebmdatalab/slack-notify-data-team
Browse files Browse the repository at this point in the history
Notify data team for import failures
  • Loading branch information
rebkwok authored Sep 20, 2023
2 parents effc625 + 45fa7a5 commit 3a0c38d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions environment-sample
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ GUNICORN_NUM_WORKERS=6
GUNICORN_LOG_LEVEL=warn

SLACK_TECHNOISE_POST_KEY=slack_technoise_post_key
SLACK_DATATEAM_POST_KEY=slack_datateam_post_key
CF_API_KEY=cf_api_key
CF_API_EMAIL=cf_api_email

Expand Down
4 changes: 1 addition & 3 deletions openprescribing/openprescribing/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,7 @@
# Webhook URLs for posting to different channels can be configured at
# https://api.slack.com/apps/A6B85C8KC/incoming-webhooks
SLACK_TECHNOISE_POST_KEY = utils.get_env_setting("SLACK_TECHNOISE_POST_KEY", default="")
SLACK_TECHSUPPORT_POST_KEY = utils.get_env_setting(
"SLACK_TECHSUPPORT_POST_KEY", default=""
)
SLACK_DATATEAM_POST_KEY = utils.get_env_setting("SLACK_DATATEAM_POST_KEY", default="")
SLACK_SENDING_ACTIVE = True


Expand Down
6 changes: 3 additions & 3 deletions openprescribing/openprescribing/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def notify_slack(message, is_error=False):
return

webhook_url = settings.SLACK_TECHNOISE_POST_KEY
techsupport_webhook_url = settings.SLACK_TECHSUPPORT_POST_KEY
datateam_webhook_url = settings.SLACK_DATATEAM_POST_KEY
slack_data = {"text": message}

response = requests.post(webhook_url, json=slack_data)
if is_error:
# Also post error messages to tech-support
response = requests.post(techsupport_webhook_url, json=slack_data)
# Also post error messages to #team-data
response = requests.post(datateam_webhook_url, json=slack_data)

if response.status_code != 200:
raise ValueError(
Expand Down

0 comments on commit 3a0c38d

Please sign in to comment.