Skip to content

Commit

Permalink
fix: actually set the cache lol
Browse files Browse the repository at this point in the history
  • Loading branch information
tuneerroy committed Dec 1, 2023
1 parent 636d820 commit 2d50889
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/dining/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from dining.api_wrapper import APIError, DiningAPIWrapper
from dining.models import DiningMenu, Venue
from dining.serializers import DiningMenuSerializer
from utils.cache import Cache


d = DiningAPIWrapper()
Expand Down Expand Up @@ -67,6 +68,7 @@ def get(self, request):
preferences = request.user.profile.dining_preferences
# aggregates venues and puts it in form {"venue_id": x, "count": x}
cached_preferences = preferences.values("venue_id").annotate(count=Count("venue_id"))
cache.set(key, cached_preferences, Cache.MONTH)
return Response({"preferences": cached_preferences})

def post(self, request):
Expand Down

0 comments on commit 2d50889

Please sign in to comment.