Skip to content

Commit

Permalink
Adds the ability for signal definitions to be disabled (Netflix#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgliss authored and rutvijmehta-harness committed Mar 17, 2023
1 parent a3f37c8 commit 830fbd3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Adds the ability to toggle signal definitions.
Revision ID: 5955ed5f76b4
Revises: 20d3801ad5b7
Create Date: 2023-03-02 11:12:18.168787
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "5955ed5f76b4"
down_revision = "20d3801ad5b7"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("signal", sa.Column("enabled", sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("signal", "enabled")
# ### end Alembic commands ###
3 changes: 3 additions & 0 deletions src/dispatch/signal/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def create_signal_instance(
variant=signal_instance_data.variant,
)

if not signal.enabled:
raise Exception("Signal definition is not enabled.")

if not signal:
raise Exception("No signal definition defined.")

Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/signal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Signal(Base, TimeStampMixin, ProjectMixin):
source_id = Column(Integer, ForeignKey("source.id"))
variant = Column(String)
loopin_signal_identity = Column(Boolean, default=False)
enabled = Column(Boolean, default=False)
case_type_id = Column(Integer, ForeignKey(CaseType.id))
case_type = relationship("CaseType", backref="signals")
case_priority_id = Column(Integer, ForeignKey(CasePriority.id))
Expand Down Expand Up @@ -211,6 +212,7 @@ class SignalBase(DispatchBase):
case_type: Optional[CaseTypeRead]
case_priority: Optional[CasePriorityRead]
external_id: str
enabled: Optional[bool] = False
external_url: Optional[str]
source: Optional[SourceBase]
created_at: Optional[datetime] = None
Expand Down
8 changes: 8 additions & 0 deletions src/dispatch/static/dispatch/src/signal/NewEditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
/>
</ValidationProvider>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="enabled"
label="Enabled"
hint="Determines whether this signal definition is currently active and should be used to process signals."
/>
</v-col>
<v-col cols="12">
<tag-filter-auto-complete
label="Tags"
Expand Down Expand Up @@ -235,6 +242,7 @@ export default {
"selected.id",
"selected.name",
"selected.description",
"selected.enabled",
"selected.variant",
"selected.owner",
"selected.external_id",
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/static/dispatch/src/signal/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const getDefaultSelectedState = () => {
external_url: null,
case_type: null,
case_priority: null,
enabled: false,
filters: null,
entity_types: null,
tags: null,
Expand Down

0 comments on commit 830fbd3

Please sign in to comment.