User cache for service in send_to_provider methods.

This will remove a call to the db if the service exists in the cache.
This commit is contained in:
Rebecca Law
2021-02-11 16:39:25 +00:00
parent 200f8aad81
commit 61af203ad6
4 changed files with 29 additions and 14 deletions

View File

@@ -28,11 +28,11 @@ from app.models import (
NOTIFICATION_SENDING,
NOTIFICATION_STATUS_TYPES_COMPLETED
)
from app.serialised_models import SerialisedTemplate
from app.serialised_models import SerialisedTemplate, SerialisedService
def send_sms_to_provider(notification):
service = notification.service
service = SerialisedService.from_id(notification.service_id)
service_id = service.id
if not service.active:
technical_failure(notification=notification)
@@ -42,7 +42,7 @@ def send_sms_to_provider(notification):
provider = provider_to_use(SMS_TYPE, notification.international)
template_dict = SerialisedTemplate.get_dict(template_id=notification.template_id,
service_id=service_id,
service_id=service.id,
version=notification.template_version)['data']
template = SMSMessageTemplate(
@@ -87,7 +87,7 @@ def send_sms_to_provider(notification):
def send_email_to_provider(notification):
service = notification.service
service = SerialisedService.from_id(notification.service_id)
service_id = service.id
if not service.active:
technical_failure(notification=notification)