Skip to content

Commit

Permalink
Moving next oncall block and preventing exception (#4259)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 authored Jan 19, 2024
1 parent c682670 commit 794a478
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/dispatch/incident/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,6 @@ def incident_create_resources(*, incident: Incident, db_session=None) -> Inciden
individual_participants, team_participants = get_incident_participants(incident, db_session)
tactical_participant_emails = [i.email for i, _ in individual_participants]

# we add any observer added in create (like new oncall participant)
participant_with_observer_role = participant_service.get_by_incident_id_and_role(
db_session=db_session, incident_id=incident.id, role=ParticipantRoleType.observer
)
if participant_with_observer_role:
# add to list
individual_participants.append(
(participant_with_observer_role.individual, participant_with_observer_role.service_id)
)

# we create the tactical group
if not incident.tactical_group:
group_flows.create_group(
Expand Down Expand Up @@ -251,6 +241,14 @@ def incident_create_resources(*, incident: Incident, db_session=None) -> Inciden
]
user_emails = list(dict.fromkeys(user_emails))

# we add any observer added in create (like new oncall participant)
participant_with_observer_role = participant_service.get_by_incident_id_and_role(
db_session=db_session, incident_id=incident.id, role=ParticipantRoleType.observer
)
if participant_with_observer_role:
# add to list
user_emails.append(participant_with_observer_role.individual.email)

for user_email in user_emails:
# we add the participant to the tactical group
group_flows.update_group(
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/participant/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_by_incident_id_and_service_id(
db_session.query(Participant)
.filter(Participant.incident_id == incident_id)
.filter(Participant.service_id == service_id)
.one_or_none()
.first()
)


Expand Down

0 comments on commit 794a478

Please sign in to comment.