From e5693531d22438909d7a8b1cadf1bccbef2745d4 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 9 Oct 2024 17:46:38 -0400 Subject: [PATCH] remove `deprecate_field` usage (#5148) --- engine/apps/alerts/models/alert.py | 3 +++ engine/apps/alerts/models/alert_group.py | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/engine/apps/alerts/models/alert.py b/engine/apps/alerts/models/alert.py index 14ae02e9d..844cbf677 100644 --- a/engine/apps/alerts/models/alert.py +++ b/engine/apps/alerts/models/alert.py @@ -25,6 +25,8 @@ from common.public_primary_keys import generate_public_primary_key, increase_public_primary_key_length if typing.TYPE_CHECKING: + from django.db.models.manager import RelatedManager + from apps.alerts.models import AlertGroup, AlertReceiveChannel, ChannelFilter logger = logging.getLogger(__name__) @@ -47,6 +49,7 @@ def generate_public_primary_key_for_alert(): class Alert(models.Model): group: typing.Optional["AlertGroup"] + resolved_alert_groups: "RelatedManager['AlertGroup']" public_primary_key = models.CharField( max_length=20, diff --git a/engine/apps/alerts/models/alert_group.py b/engine/apps/alerts/models/alert_group.py index 2e3827212..7a7b4e193 100644 --- a/engine/apps/alerts/models/alert_group.py +++ b/engine/apps/alerts/models/alert_group.py @@ -12,7 +12,6 @@ from django.db.models import JSONField, Q, QuerySet from django.utils import timezone from django.utils.functional import cached_property -from django_deprecate_fields import deprecate_field from apps.alerts.constants import ActionSource, AlertGroupState from apps.alerts.escalation_snapshot import EscalationSnapshotMixin @@ -288,17 +287,20 @@ class AlertGroup(AlertGroupSlackRenderingMixin, EscalationSnapshotMixin, models. related_name="resolved_alert_groups", ) - # NOTE: see https://raintank-corp.slack.com/archives/C07RGREUH4Z/p1728494111646319 - # This field should eventually be dropped as it's no longer being set/read anywhere - resolved_by_alert = deprecate_field( - models.ForeignKey( - "alerts.Alert", - on_delete=models.SET_NULL, - null=True, - default=None, - related_name="resolved_alert_groups", - ) + resolved_by_alert = models.ForeignKey( + "alerts.Alert", + on_delete=models.SET_NULL, + null=True, + default=None, + related_name="resolved_alert_groups", ) + """ + ⚠️ This field is no longer being set/read anywhere, DON'T USE IT! ⚠️ + + TODO: We still need to figure out how to remove it safely. + + See [this conversation](https://raintank-corp.slack.com/archives/C07RGREUH4Z/p1728494111646319) for more context + """ resolved_at = models.DateTimeField(blank=True, null=True) acknowledged = models.BooleanField(default=False)