mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-04 22:28:25 -04:00
Cache email branding in Redis
If we’re going to be referring to email branding as part of the service creation journey then we should make sure it doesn’t slow things down too much by adding an extra API call. Caching things in Redis is a way of avoiding unneeded API calls.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
from app.notify_client import NotifyAdminAPIClient, cache
|
||||
|
||||
|
||||
class EmailBrandingClient(NotifyAdminAPIClient):
|
||||
@@ -6,9 +6,11 @@ class EmailBrandingClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
@cache.set('email_branding-{branding_id}')
|
||||
def get_email_branding(self, branding_id):
|
||||
return self.get(url='/email-branding/{}'.format(branding_id))
|
||||
|
||||
@cache.set('email_branding')
|
||||
def get_all_email_branding(self, sort_key=None):
|
||||
brandings = self.get(url='/email-branding')['email_branding']
|
||||
if sort_key and sort_key in brandings[0]:
|
||||
@@ -18,6 +20,7 @@ class EmailBrandingClient(NotifyAdminAPIClient):
|
||||
def get_letter_email_branding(self):
|
||||
return self.get(url='/dvla_organisations')
|
||||
|
||||
@cache.delete('email_branding')
|
||||
def create_email_branding(self, logo, name, text, colour, domain, brand_type):
|
||||
data = {
|
||||
"logo": logo,
|
||||
@@ -29,6 +32,8 @@ class EmailBrandingClient(NotifyAdminAPIClient):
|
||||
}
|
||||
return self.post(url="/email-branding", data=data)
|
||||
|
||||
@cache.delete('email_branding')
|
||||
@cache.delete('email_branding-{branding_id}')
|
||||
def update_email_branding(self, branding_id, logo, name, text, colour, domain, brand_type):
|
||||
data = {
|
||||
"logo": logo,
|
||||
|
||||
Reference in New Issue
Block a user