diff --git a/src/dispatch/incident/flows.py b/src/dispatch/incident/flows.py index c3d4a9394085..d8dfa016efcd 100644 --- a/src/dispatch/incident/flows.py +++ b/src/dispatch/incident/flows.py @@ -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( @@ -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( diff --git a/src/dispatch/participant/service.py b/src/dispatch/participant/service.py index 0ea0d73965c1..563ee3d018b6 100644 --- a/src/dispatch/participant/service.py +++ b/src/dispatch/participant/service.py @@ -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() )