Skip to content

Commit

Permalink
Adding owner and pinned fields to events
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 committed Sep 29, 2023
1 parent b0786c3 commit 58de4b4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dispatch/event/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def log_incident_event(
db_session=db_session, email=user_email, project_id=incident.project.id
)
event_in.source = f"Custom event created by {individual.name}"
event_in.owner = individual.name

event_service.log_incident_event(
db_session=db_session,
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/event/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ class EventCreateMinimal(DispatchBase):
description: str
details: dict
type: Optional[str]
owner: Optional[str]
2 changes: 2 additions & 0 deletions src/dispatch/event/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def log_incident_event(
ended_at: datetime = None,
details: dict = None,
type: str = EventType.other,
owner: str = "",
) -> Event:
"""Logs an event in the incident timeline."""
uuid = uuid4()
Expand All @@ -96,6 +97,7 @@ def log_incident_event(
description=description,
details=details,
type=type,
owner=owner,
)
event = create(db_session=db_session, event_in=event_in)

Expand Down
7 changes: 7 additions & 0 deletions src/dispatch/incident/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ def conversation_topic_dispatcher(
incident_id=incident.id,
individual_id=individual.id,
type=EventType.field_updated,
owner=individual.name,
)

if previous_incident.description != incident.description:
Expand All @@ -500,6 +501,7 @@ def conversation_topic_dispatcher(
incident_id=incident.id,
individual_id=individual.id,
type=EventType.field_updated,
owner=individual.name,
)

description, details = check_for_tag_change(
Expand All @@ -514,6 +516,7 @@ def conversation_topic_dispatcher(
incident_id=incident.id,
individual_id=individual.id,
type=EventType.field_updated,
owner=individual.name,
)

if previous_incident.incident_type.name != incident.incident_type.name:
Expand All @@ -526,6 +529,7 @@ def conversation_topic_dispatcher(
incident_id=incident.id,
individual_id=individual.id,
type=EventType.field_updated,
owner=individual.name,
)

if previous_incident.incident_severity.name != incident.incident_severity.name:
Expand All @@ -538,6 +542,7 @@ def conversation_topic_dispatcher(
incident_id=incident.id,
individual_id=individual.id,
type=EventType.assessment_updated,
owner=individual.name,
)

if previous_incident.incident_priority.name != incident.incident_priority.name:
Expand All @@ -550,6 +555,7 @@ def conversation_topic_dispatcher(
incident_id=incident.id,
individual_id=individual.id,
type=EventType.assessment_updated,
owner=individual.name,
)

if previous_incident.status != incident.status:
Expand All @@ -562,6 +568,7 @@ def conversation_topic_dispatcher(
incident_id=incident.id,
individual_id=individual.id,
type=EventType.assessment_updated,
owner=individual.name,
)

if conversation_topic_change:
Expand Down
3 changes: 3 additions & 0 deletions src/dispatch/incident/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def create(*, db_session, incident_in: IncidentCreate) -> Incident:
db_session.add(incident)
db_session.commit()

reporter_name = incident_in.reporter.individual.name if incident_in.reporter else ""

event_service.log_incident_event(
db_session=db_session,
source="Dispatch Core App",
Expand All @@ -207,6 +209,7 @@ def create(*, db_session, incident_in: IncidentCreate) -> Incident:
"visibility": incident.visibility,
},
incident_id=incident.id,
owner=reporter_name
)

# add reporter
Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ def handle_timeline_added_event(
individual_id=individual.id,
started_at=message_ts_utc,
type=EventType.imported_message,
owner=individual.name,
)


Expand Down Expand Up @@ -1049,6 +1050,7 @@ def handle_add_timeline_submission_event(
incident_id=context["subject"].id,
individual_id=participant.individual.id,
type=EventType.imported_message,
owner=participant.individual.name,
)

send_success_modal(
Expand Down

0 comments on commit 58de4b4

Please sign in to comment.