Skip to content

Commit

Permalink
remove deprecate_field usage (#5148)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyorlando authored Oct 9, 2024
1 parent e11ae8a commit e569353
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions engine/apps/alerts/models/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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,
Expand Down
24 changes: 13 additions & 11 deletions engine/apps/alerts/models/alert_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e569353

Please sign in to comment.