Skip to content

Commit

Permalink
Enhance : Cache on the endpoint for key api stats
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Oct 15, 2024
1 parent a9f14de commit 40b8060
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
)
from django.shortcuts import get_object_or_404, redirect
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from django.views.decorators.vary import vary_on_cookie, vary_on_headers
from django_filters.rest_framework import DjangoFilterBackend
from drf_yasg.utils import swagger_auto_schema
from geojson2osm import geojson2osm
Expand Down Expand Up @@ -865,6 +868,8 @@ def get_queryset(self):
) | Banner.objects.filter(end_date__isnull=True)


@cache_page(60 * 15) ## Cache for 15 mins
# @vary_on_cookie , if you wanna do user specific cache
@api_view(["GET"])
def get_kpi_stats(request):
total_models_with_status_published = Model.objects.filter(status=0).count()
Expand Down

0 comments on commit 40b8060

Please sign in to comment.