Skip to content

Commit 255b49d

Browse files
authored
Add environment variable for slack webhook failures_only (#48)
Add SENSORSAFRICA_CELERY_SLACK_WEBHOOK_FAILURES_ONLY environment variable for slack webhook failures_only option
1 parent ae7e3b6 commit 255b49d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sensorsafrica/celeryapp.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@
1616
# Autodiscover tasks in tasks.py
1717
app.autodiscover_tasks()
1818

19-
slack_app = Slackify(app, os.environ.get("SENSORSAFRICA_CELERY_SLACK_WEBHOOK", ""))
19+
SLACK_WEBHOOK = os.environ.get("SENSORSAFRICA_CELERY_SLACK_WEBHOOK", "")
20+
SLACK_WEBHOOK_FAILURES_ONLY = os.environ.get(
21+
"SENSORSAFRICA_CELERY_SLACK_WEBHOOK_FAILURES_ONLY", "").strip().lower() in ('true', 't', '1')
22+
23+
options = {'failures_only': SLACK_WEBHOOK_FAILURES_ONLY}
24+
25+
slack_app = Slackify(app, SLACK_WEBHOOK, **options)

0 commit comments

Comments
 (0)