Skip to content

Commit

Permalink
Added keyword for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
k-macmillan committed Nov 30, 2024
1 parent 6ac8387 commit 85ecb35
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 4 additions & 2 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,14 @@ def save_sms(

if is_feature_enabled(FeatureFlag.SMS_SENDER_RATE_LIMIT_ENABLED) and sms_sender and sms_sender.rate_limit:
provider_tasks.deliver_sms_with_rate_limiting.apply_async(
[str(saved_notification.id)],
args=[],
kwargs={'notification_id': str(saved_notification.id)},
queue=QueueNames.SEND_SMS if not service.research_mode else QueueNames.NOTIFY,
)
else:
provider_tasks.deliver_sms.apply_async(
[str(saved_notification.id)],
args=[],
kwargs={'notification_id': str(saved_notification.id)},
queue=QueueNames.SEND_SMS if not service.research_mode else QueueNames.NOTIFY,
)

Expand Down
1 change: 1 addition & 0 deletions app/clients/email/aws_ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def send_email( # noqa: C901
html_body='',
reply_to_address=None,
attachments=None,
notification_id=None,
):
def create_mime_base(
attachments,
Expand Down
19 changes: 13 additions & 6 deletions app/notifications/process_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,18 @@ def send_notification_to_queue(

if communication_item_id is not None:
if recipient_id_type != IdentifierType.VA_PROFILE_ID.value:
tasks.append(lookup_va_profile_id.si(notification.id).set(queue=QueueNames.LOOKUP_VA_PROFILE_ID))
tasks.append(
lookup_va_profile_id.si(notification_id=str(notification.id)).set(
queue=QueueNames.LOOKUP_VA_PROFILE_ID
)
)

# Including sms_sender_id is necessary so the correct sender can be chosen.
# https://docs.celeryq.dev/en/v4.4.7/userguide/canvas.html#immutability
deliver_task, queue = _get_delivery_task(notification, research_mode, queue, sms_sender_id)
tasks.append(deliver_task.si(str(notification.id), sms_sender_id).set(queue=queue))
deliver_task, queue = _get_delivery_task(
notification, research_mode, queue, sms_sender_id, notification_id=str(notification.id)
)
tasks.append(deliver_task.si(notification_id=str(notification.id), sms_sender_id=sms_sender_id).set(queue=queue))

try:
# This executes the task list. Each task calls a function that makes a request to
Expand All @@ -199,6 +205,7 @@ def _get_delivery_task(
research_mode=False,
queue=None,
sms_sender_id=None,
notification_id=None,
):
"""
The return value "deliver_task" is a function decorated to be a Celery task.
Expand Down Expand Up @@ -261,15 +268,15 @@ def send_to_queue_for_recipient_info_based_on_recipient_identifier(

else:
tasks = [
lookup_va_profile_id.si(notification.id).set(queue=QueueNames.LOOKUP_VA_PROFILE_ID),
lookup_va_profile_id.si(notification_id=notification.id).set(queue=QueueNames.LOOKUP_VA_PROFILE_ID),
send_va_onsite_notification_task.s(str(notification.template.id), onsite_enabled).set(
queue=QueueNames.NOTIFY
),
]

tasks.append(lookup_contact_info.si(notification.id).set(queue=QueueNames.LOOKUP_CONTACT_INFO))
deliver_task, deliver_queue = _get_delivery_task(notification)
tasks.append(deliver_task.si(notification.id).set(queue=deliver_queue))
deliver_task, deliver_queue = _get_delivery_task(notification, notification_id=notification.id)
tasks.append(deliver_task.si(notification.id, notification_id=notification.id).set(queue=deliver_queue))

try:
# This executes the task list. Each task calls a function that makes a request to
Expand Down

0 comments on commit 85ecb35

Please sign in to comment.