diff --git a/app/celery/common.py b/app/celery/common.py index c1cea6bcd2..8e6a5f5670 100644 --- a/app/celery/common.py +++ b/app/celery/common.py @@ -1,4 +1,4 @@ -import datetime +from datetime import datetime, timezone from uuid import UUID from flask import current_app @@ -94,18 +94,14 @@ def log_and_update_permanent_failure( def log_notification_total_time( notification_id: UUID, - start_time: datetime.datetime, + start_time: datetime, status: str, provider: str, - event_timestamp_in_ms: str | None = None, + event_timestamp: datetime | None = None, ) -> None: """Logs how long it took a notification to go from created to delivered""" if status == NOTIFICATION_DELIVERED: - end_time = ( - datetime.datetime.fromtimestamp(int(event_timestamp_in_ms) / 1000) - if event_timestamp_in_ms - else datetime.datetime.now() - ) + end_time = event_timestamp or datetime.now(timezone.utc).replace(tzinfo=None) current_app.logger.info( 'notification %s took %ss total time to reach %s status - %s', notification_id, diff --git a/app/clients/sms/__init__.py b/app/clients/sms/__init__.py index 91b986acda..2ae71a05dd 100644 --- a/app/clients/sms/__init__.py +++ b/app/clients/sms/__init__.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from datetime import datetime, timezone +from datetime import datetime from app.clients import Client, ClientException @@ -36,7 +36,7 @@ class SmsStatusRecord: provider: str message_parts: int = 1 price_millicents: float = 0.0 - provider_updated_at: datetime = datetime.now(timezone.utc) + provider_updated_at: datetime | None = None class SmsClient(Client):