Skip to content

Commit 5761297

Browse files
committed
wip
1 parent 825a6c2 commit 5761297

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

lung_cancer_screening/questions/management/commands/request_summary.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,33 @@ class Command(BaseCommand):
99
help = "Counts the number of submitted requests."
1010

1111
def handle(self, *args, **options):
12-
logger.info("Command: SubmittedCount.")
12+
13+
logger.info("Command: Request Summary.")
1314
try:
1415
rs = RequestSummary()
1516
summary = rs.get_summary()
1617

1718
self.stdout.write(str(summary))
1819

20+
slack_webhook_url = os.environ.get("SLACK_WEBHOOK_URL")
21+
22+
if not slack_webhook_url:
23+
logger.warning("SLACK_WEBHOOK_URL is not set; skipping Slack notification.")
24+
return
25+
26+
payload = {
27+
"text": f"*Request summary*\n```{json.dumps(summary, indent=2, default=str)}```"
28+
}
29+
30+
response = requests.post(
31+
slack_webhook_url,
32+
json=payload,
33+
timeout=10,
34+
)
35+
response.raise_for_status()
36+
37+
logger.info("Request summary sent to Slack.")
38+
1939
except Exception as e:
2040
logger.error(e, exc_info=True)
2141
raise CommandError(e)

0 commit comments

Comments
 (0)