Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 19aae08

Browse files
authored
add timers to func calls in add_or_reactivate_participant (#2967)
* add timers to func calls in add_or_reactivate_participant * add timer to incident.get
1 parent c631b43 commit 19aae08

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

src/dispatch/incident/flows.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from typing import Any, List
55

6+
from dispatch.decorators import timer
67
from dispatch.conference import service as conference_service
78
from dispatch.conference.models import ConferenceCreate
89
from dispatch.conversation import service as conversation_service
@@ -599,6 +600,7 @@ def set_conversation_bookmarks(incident: Incident, db_session: SessionLocal):
599600
log.exception(e)
600601

601602

603+
@timer
602604
def add_participants_to_conversation(
603605
participant_emails: List[str], incident: Incident, db_session: SessionLocal
604606
):
@@ -630,6 +632,7 @@ def add_participants_to_conversation(
630632
log.exception(e)
631633

632634

635+
@timer
633636
def add_participant_to_tactical_group(
634637
user_email: str, incident: Incident, db_session: SessionLocal
635638
):

src/dispatch/incident/messaging.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77
import logging
88

9+
from dispatch.decorators import timer
910
from dispatch.config import DISPATCH_UI_URL
1011
from dispatch.conversation.enums import ConversationCommands
1112
from dispatch.database.core import SessionLocal, resolve_attr
@@ -214,6 +215,7 @@ def send_welcome_email_to_participant(
214215
log.debug(f"Welcome email sent to {participant_email}.")
215216

216217

218+
@timer
217219
def send_incident_welcome_participant_messages(
218220
participant_email: str, incident: Incident, db_session: SessionLocal
219221
):
@@ -227,6 +229,7 @@ def send_incident_welcome_participant_messages(
227229
log.debug(f"Welcome participant messages sent {participant_email}.")
228230

229231

232+
@timer
230233
def get_suggested_document_items(incident: Incident, db_session: SessionLocal):
231234
"""Create the suggested document item message."""
232235
suggested_documents = get_suggested_documents(db_session, incident)
@@ -246,6 +249,7 @@ def get_suggested_document_items(incident: Incident, db_session: SessionLocal):
246249
return items
247250

248251

252+
@timer
249253
def send_incident_suggested_reading_messages(
250254
incident: Incident, items: list, participant_email: str, db_session: SessionLocal
251255
):
@@ -464,6 +468,7 @@ def send_incident_update_notifications(
464468
log.debug("Incident updated notifications sent.")
465469

466470

471+
@timer
467472
def send_incident_participant_announcement_message(
468473
participant_email: str, incident: Incident, db_session: SessionLocal
469474
):

src/dispatch/incident/service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import List, Optional
1111
from pydantic.error_wrappers import ErrorWrapper, ValidationError
1212

13+
from dispatch.decorators import timer
1314
from dispatch.case import service as case_service
1415
from dispatch.database.core import SessionLocal
1516
from dispatch.event import service as event_service
@@ -62,6 +63,7 @@ def resolve_and_associate_role(
6263
return email_address, service_id
6364

6465

66+
@timer
6567
def get(*, db_session, incident_id: int) -> Optional[Incident]:
6668
"""Returns an incident based on the given id."""
6769
return db_session.query(Incident).filter(Incident.id == incident_id).first()

src/dispatch/participant/flows.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
from typing import TypeVar
33

4+
from dispatch.decorators import timer
45
from dispatch.case.models import Case
56
from dispatch.database.core import SessionLocal, get_table_name_by_class_instance
67
from dispatch.event import service as event_service
@@ -21,6 +22,7 @@
2122
Subject = TypeVar("Subject", Case, Incident)
2223

2324

25+
@timer
2426
def add_participant(
2527
user_email: str,
2628
subject: Subject,
@@ -147,6 +149,7 @@ def inactivate_participant(user_email: str, incident: Incident, db_session: Sess
147149
return True
148150

149151

152+
@timer
150153
def reactivate_participant(
151154
user_email: str, incident: Incident, db_session: SessionLocal, service_id: int = None
152155
):

src/dispatch/participant/service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List, Optional
22

3+
from dispatch.decorators import timer
34
from dispatch.case import service as case_service
45
from dispatch.incident import service as incident_service
56
from dispatch.individual import service as individual_service
@@ -43,6 +44,7 @@ def get_by_case_id_and_role(*, db_session, case_id: int, role: str) -> Optional[
4344
)
4445

4546

47+
@timer
4648
def get_by_incident_id_and_email(
4749
*, db_session, incident_id: int, email: str
4850
) -> Optional[Participant]:
@@ -67,6 +69,7 @@ def get_by_case_id_and_email(*, db_session, case_id: int, email: str) -> Optiona
6769
)
6870

6971

72+
@timer
7073
def get_by_incident_id_and_service_id(
7174
*, db_session, incident_id: int, service_id: int
7275
) -> Optional[Participant]:

0 commit comments

Comments
 (0)