Skip to content

Commit

Permalink
create relationships for the data condition model
Browse files Browse the repository at this point in the history
  • Loading branch information
saponifi3d committed Sep 13, 2024
1 parent 7e4c968 commit 8e3a50d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/sentry/workflow_engine/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = ["DataSource", "Detector", "Workflow", "WorkflowAction"]
__all__ = ["DataCondition", "DataSource", "Detector", "Workflow", "WorkflowAction"]

from .data_condition import DataCondition
from .data_source import DataSource
from .detector import Detector
from .workflow import Workflow
Expand Down
4 changes: 4 additions & 0 deletions src/sentry/workflow_engine/models/data_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from sentry.backup.scopes import RelocationScope
from sentry.db.models import DefaultFieldsModel, region_silo_model, sane_repr
from sentry.workflow_engine.models import Detector, WorkflowAction


@region_silo_model
Expand All @@ -17,3 +18,6 @@ class DataCondition(DefaultFieldsModel):
threshold = models.FloatField()
condition_result = models.JSONField()
type = models.CharField(max_length=200)

detectors = models.ForeignKey(Detector, on_delete=models.CASCADE)
workflow_action = models.ForeignKey(WorkflowAction, on_delete=models.CASCADE)
3 changes: 1 addition & 2 deletions src/sentry/workflow_engine/models/workflow_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class WorkflowAction(DefaultFieldsModel):
"""

__relocation_scope__ = RelocationScope.Organization
__repr__ = sane_repr("workflow_id", "type")

class Type(models.TextChoices):
NOTIFICATION = "SendNotificationAction"
Expand All @@ -20,5 +21,3 @@ class Type(models.TextChoices):
workflow = FlexibleForeignKey("workflow_engine.Workflow")
type = models.TextField(choices=Type.choices)
data = models.JSONField(default=dict)

__repr__ = sane_repr("workflow_id", "type")

0 comments on commit 8e3a50d

Please sign in to comment.