mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
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:
@@ -430,6 +430,7 @@ class Development(Config):
|
||||
|
||||
|
||||
class Test(Development):
|
||||
SQLALCHEMY_ECHO = False
|
||||
NOTIFY_EMAIL_DOMAIN = 'test.notify.com'
|
||||
FROM_NUMBER = 'testing'
|
||||
NOTIFY_ENVIRONMENT = 'test'
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -75,6 +75,7 @@ class SerialisedTemplate(SerialisedModel):
|
||||
class SerialisedService(SerialisedModel):
|
||||
ALLOWED_PROPERTIES = {
|
||||
'id',
|
||||
'name',
|
||||
'active',
|
||||
'contact_link',
|
||||
'email_from',
|
||||
@@ -83,6 +84,8 @@ class SerialisedService(SerialisedModel):
|
||||
'rate_limit',
|
||||
'research_mode',
|
||||
'restricted',
|
||||
'prefix_sms',
|
||||
'email_branding'
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user