Skip to content

Commit

Permalink
Resolved timestamp issues
Browse files Browse the repository at this point in the history
  • Loading branch information
k-macmillan committed Oct 28, 2024
1 parent 0323b1d commit fb9fc99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions app/celery/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import datetime
from datetime import datetime, timezone
from uuid import UUID

from flask import current_app
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/clients/sms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from datetime import datetime, timezone
from datetime import datetime

from app.clients import Client, ClientException

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit fb9fc99

Please sign in to comment.