From 1bb51fe69093c62ec28d9e4b1c2b8bf614da8b1f Mon Sep 17 00:00:00 2001 From: David Reed Date: Fri, 22 Sep 2023 02:04:24 +0000 Subject: [PATCH 1/3] Fix incorrect unit --- config/settings/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 576b3c979..bd31cfe98 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -459,8 +459,8 @@ def safe_key() -> str: 'rest_framework.throttling.UserRateThrottle' ], 'DEFAULT_THROTTLE_RATES': { - 'anon': '4/sec', - 'user': '4/sec' + 'anon': '4/second', + 'user': '4/second' } } From 1dd98b3983be1bd94adb3730d0330cb91cd2dda8 Mon Sep 17 00:00:00 2001 From: David Reed Date: Fri, 22 Sep 2023 03:08:39 +0000 Subject: [PATCH 2/3] Add caching for hot ProductCategory endpoint --- metadeploy/api/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/metadeploy/api/views.py b/metadeploy/api/views.py index 9c3a30faf..e6f00ae7f 100644 --- a/metadeploy/api/views.py +++ b/metadeploy/api/views.py @@ -2,6 +2,8 @@ from functools import reduce from logging import getLogger from pathlib import Path +from django.utils.decorators import method_decorator +from django.views.decorators.cache import cache_page import django_rq from django.conf import settings @@ -157,6 +159,10 @@ class ProductCategoryViewSet(viewsets.ReadOnlyModelViewSet): serializer_class = ProductCategorySerializer queryset = ProductCategory.objects.all() + @method_decorator(cache_page(60*60*2)) + def list(self, *args, **kwargs): + return super().list(*args, **kwargs) + class ProductViewSet( FilterAllowedByOrgMixin, GetOneMixin, viewsets.ReadOnlyModelViewSet From c8ec070bf58e23367f845a4ea063faf15b5f3be5 Mon Sep 17 00:00:00 2001 From: David Reed Date: Fri, 22 Sep 2023 17:00:33 +0000 Subject: [PATCH 3/3] Ignore coverage --- metadeploy/api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadeploy/api/views.py b/metadeploy/api/views.py index e6f00ae7f..da63c7e83 100644 --- a/metadeploy/api/views.py +++ b/metadeploy/api/views.py @@ -161,7 +161,7 @@ class ProductCategoryViewSet(viewsets.ReadOnlyModelViewSet): @method_decorator(cache_page(60*60*2)) def list(self, *args, **kwargs): - return super().list(*args, **kwargs) + return super().list(*args, **kwargs) # pragma: nocover class ProductViewSet(