From b26c6ba179b3eca1f276d4149a971cf735846de6 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Sat, 25 Mar 2023 14:27:32 +0530 Subject: [PATCH] feat: add some caching Signed-off-by: Ameya Shenoy --- backend/foldbank/api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/foldbank/api.py b/backend/foldbank/api.py index 2714c03..f749def 100644 --- a/backend/foldbank/api.py +++ b/backend/foldbank/api.py @@ -4,6 +4,8 @@ from random import randrange from django.conf import settings from django.contrib.auth import get_user_model +from django.utils.decorators import method_decorator +from django.views.decorators.cache import cache_page from drf_yasg import openapi from drf_yasg.utils import swagger_auto_schema from foldbank.models import Account, RecurringPayment, Transaction, User @@ -131,6 +133,7 @@ class TransactionsAPI(generics.ListAPIView): }, tags=["Transactions"], ) + @method_decorator(cache_page(60 * 60 * 2)) def get(self, request): qs = [] @@ -190,6 +193,7 @@ class AccountsAPI(generics.ListAPIView): }, tags=["Accounts"], ) + @method_decorator(cache_page(60 * 60 * 2)) def get(self, request): qs = [] @@ -240,8 +244,9 @@ class UpcomingRecurringPaymentAPI(generics.ListAPIView): }, ) - - success_response = openapi.Response("Success Response", UpcomingRecurringPaymentOutputSerializer) + success_response = openapi.Response( + "Success Response", UpcomingRecurringPaymentOutputSerializer + ) @swagger_auto_schema( operation_summary="Recurring Payments List", @@ -250,6 +255,7 @@ class UpcomingRecurringPaymentAPI(generics.ListAPIView): }, tags=["Recurring Payments"], ) + @method_decorator(cache_page(60 * 60 * 2)) def get(self, request): qs = []