-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: convert organization.general_log_channel_id
to organization.general_log_slack_channel
#5191
base: dev
Are you sure you want to change the base?
Conversation
…general_log_slack_channel`
organization.general_log_channel_id
to organization.general_log_slack_channel
general_log_channel_id = models.CharField(max_length=100, null=True, default=None) | ||
|
||
general_log_slack_channel = models.ForeignKey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: suggest renaming this field to default_slack_channel
or general_slack_channel
. wdyt?
slack_channel = SlackChannel.objects.get(slack_id=slack_id, slack_team_identity=slack_team_identity) | ||
|
||
org.general_log_slack_channel = slack_channel | ||
org.save(update_fields=['general_log_slack_channel']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd propose to use bulk_update
here
organization = make_organization( | ||
slack_team_identity=slack_team_identity, general_log_channel_id="DEFAULT_CHANNEL_ID" | ||
) | ||
slack_channel = make_slack_channel(slack_team_identity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should fix failing test (channel slack id is checked below (line 111)):
slack_channel = make_slack_channel(slack_team_identity) | |
slack_channel = make_slack_channel(slack_team_identity, slack_id="DEFAULT_CHANNEL_ID") |
🙏
return None | ||
try: | ||
channel = obj.slack_team_identity.get_cached_channels().get(slack_id=obj.general_log_channel_id) | ||
channel = slack_team_identity.get_cached_channels().get(slack_id=org_general_log_channel_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do channel = obj.general_log_slack_channel
here instead of slack_team_identity.get_cached_channels().get
? 🤔
What this PR does
Related to https://github.com/grafana/oncall-private/issues/2947
Right now
general_log_channel_id
is just a string value representing the Slack Channel ID (ex.C043HQ70QMB
). This PR migrates this instead to be a foreign key relationship on theslack_slackchannel
table and updates all references togeneral_log_channel_id
.Tested migrations locally:
Future incoming PRs
Organization.general_log_channel_id
columnChannelFilter.slack_channel_id
andResolutionNoteSlackMessage.slack_channel_id
to use foreign key relationshipsChecklist
pr:no public docs
PR label added if not required)release:
). These labels dictate how your PR willshow up in the autogenerated release notes.