Skip to content

Commit

Permalink
Add a new slack slash command /dispatch-list-signals and allow crea…
Browse files Browse the repository at this point in the history
…tion of Snooze filter w/ MFA (#3050)

* Initial pass at adding a /list-signals command and snooze w/ MFA

* Initial pass at adding a /list-signals command and snooze w/ MFA

* remove print statement

* add docs

* add docstrings, missing types

* Add a preview intermediary modal

* calculate relative date on signal filter create

* remove signal service imports

* black formatting

* add casetype model to signal service

* remove datetime unused import
  • Loading branch information
wssheldon authored Mar 3, 2023
1 parent 4477d71 commit 6f94abf
Show file tree
Hide file tree
Showing 9 changed files with 884 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ You can override their values if you wish to do so. Included below are their des
| `/dispatch-list-incidents <organization-slug\|'default'> <project-slug\|'default'>` | Lists current active and stable incidents and closed incidents in the last 24 hours. |
| `/dispatch-list-my-tasks` | Opens a modal with the list of your open and resolved incident tasks. |
| `/dispatch-list-participants` | Opens a modal with the list of incident participants. |
| `/dispatch-list-signals` | Opens a modal with the list of signal definitions configured for the conversation from where command was ran. |
| `/dispatch-list-tasks` | Opens a modal with the list of open and resolved incident tasks. |
| `/dispatch-list-workflows` | List workflows previously run during this incident. |
| `/dispatch-report-executive` | Opens a modal to write an executive report. |
Expand Down
21 changes: 21 additions & 0 deletions src/dispatch/entity/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,27 @@ def get_signal_instances_with_entity(
return signal_instances


def get_signal_instances_with_entities(
db_session: Session, signal_id: int, entity_ids: list[int], days_back: int
) -> list[SignalInstance]:
"""Searches a signal instance with the same entities within a given timeframe."""
# Calculate the datetime for the start of the search window
start_date = datetime.utcnow() - timedelta(days=days_back)

# Query for signal instances containing the entity within the search window
signal_instances = (
db_session.query(SignalInstance)
.options(joinedload(SignalInstance.signal))
.join(SignalInstance.entities)
.filter(SignalInstance.created_at >= start_date)
.filter(SignalInstance.signal_id == signal_id)
.filter(Entity.id.in_(entity_ids))
.all()
)

return signal_instances


EntityTypePair = NewType(
"EntityTypePair",
NamedTuple(
Expand Down
11 changes: 11 additions & 0 deletions src/dispatch/plugins/dispatch_slack/case/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


class CaseNotificationActions(DispatchEnum):
snooze = "case-notification-snooze"
escalate = "case-notification-escalate"
resolve = "case-notification-resolve"
reopen = "case-notification-reopen"
Expand All @@ -10,6 +11,11 @@ class CaseNotificationActions(DispatchEnum):
join_incident = "case-notification-join-incident"


class CasePaginateActions(DispatchEnum):
list_signal_next = "case-list-signal-next"
list_signal_previous = "case-list-signal-previous"


class CaseEditActions(DispatchEnum):
submit = "case-notification-edit-submit"

Expand All @@ -18,6 +24,11 @@ class CaseResolveActions(DispatchEnum):
submit = "case-notification-resolve-submit"


class CaseSnoozeActions(DispatchEnum):
preview = "case-notification-snooze-preview"
submit = "case-notification-snooze-submit"


class CaseEscalateActions(DispatchEnum):
submit = "case-notification-escalate-submit"
project_select = "case-notification-escalate-project-select"
Expand Down
Loading

0 comments on commit 6f94abf

Please sign in to comment.