Currently any time that CommsChannel.channel_name is requested, we go and fetch it from the Slack API. This leads to rate limiting issues when listing a large number of incidents, as Response will call the Slack API for every single incident.
This change caches the channel name in a new model field, updating it whenever we get a channel_rename event from Slack. One complication is that we'd like to backfill this for existing CommsChannels in the database (and make the field non-nullable) - I've written a reasonably complex migration that fetches CommsChannel names and populates the field. This has the unfortunate side-effect of requiring a valid SLACK_TOKEN environment variable when running migrations.
TODO:
[ ] Test this better - especially the Slack API retry/backoff
Currently any time that
CommsChannel.channel_name
is requested, we go and fetch it from the Slack API. This leads to rate limiting issues when listing a large number of incidents, as Response will call the Slack API for every single incident.This change caches the channel name in a new model field, updating it whenever we get a
channel_rename
event from Slack. One complication is that we'd like to backfill this for existing CommsChannels in the database (and make the field non-nullable) - I've written a reasonably complex migration that fetches CommsChannel names and populates the field. This has the unfortunate side-effect of requiring a validSLACK_TOKEN
environment variable when running migrations.TODO: