Skip to content
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(incident): allow exclusion of incident types from reminders #5781

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Adds column to exclude incident types from reminders

Revision ID: 2f18776252bb
Revises: 8790ff1c8d6d
Create Date: 2025-02-17 14:52:36.771074

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "2f18776252bb"
down_revision = "8790ff1c8d6d"
branch_labels = None
depends_on = None


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


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("incident_type", "exclude_from_reminders")
# ### end Alembic commands ###
2 changes: 2 additions & 0 deletions src/dispatch/incident/type/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class IncidentType(ProjectMixin, Base):
enabled = Column(Boolean, default=True)
default = Column(Boolean, default=False)
visibility = Column(String, default=Visibility.open)
exclude_from_reminders = Column(Boolean, default=False)
plugin_metadata = Column(JSON, default=[])
task_plugin_metadata = Column(JSON, default=[])

Expand Down Expand Up @@ -114,6 +115,7 @@ class IncidentTypeBase(DispatchBase):
review_template_document: Optional[Document]
tracking_template_document: Optional[Document]
exclude_from_metrics: Optional[bool] = False
exclude_from_reminders: Optional[bool] = False
default: Optional[bool] = False
project: Optional[ProjectRead]
plugin_metadata: List[PluginMetadata] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@
hint="Check if this incident type should be excluded from all metrics."
/>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="exclude_from_reminders"
label="Exclude from Reminders"
hint="Check if this incident type should be excluded from receiving reminders."
/>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="default_incident_type"
Expand Down Expand Up @@ -223,6 +230,7 @@ export default {
"selected.enabled",
"selected.cost_model",
"selected.exclude_from_metrics",
"selected.exclude_from_reminders",
"selected.default",
"selected.channel_description",
"selected.description_service",
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/static/dispatch/src/incident/type/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const getDefaultSelectedState = () => {
loading: false,
plugin_metadata: [],
exclude_from_metrics: null,
exclude_from_reminders: null,
enabled: false,
default: false,
project: null,
Expand Down
3 changes: 3 additions & 0 deletions src/dispatch/task/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from dispatch.incident import flows as incident_flows
from dispatch.incident.flows import incident_service
from dispatch.incident.models import Incident
from dispatch.incident.type.models import IncidentType
from dispatch.plugin import service as plugin_service
from dispatch.participant import service as participant_service
from dispatch.incident.messaging import send_task_add_ephemeral_message
Expand Down Expand Up @@ -54,9 +55,11 @@ def get_overdue_tasks(*, db_session, project_id: int) -> List[Optional[Task]]:
return (
db_session.query(Task)
.join(Incident)
.join(IncidentType)
.filter(Task.status == TaskStatus.open)
.filter(Task.reminders == True) # noqa
.filter(Incident.project_id == project_id)
.filter(IncidentType.exclude_from_reminders.isnot(True))
.filter(Task.resolve_by < datetime.utcnow())
.filter(
or_(
Expand Down
Loading