Skip to content

Commit

Permalink
eat(favorites): Adds logic to retrieve and use cached stats
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Dec 18, 2024
1 parent 98c912b commit 3a64767
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cl/favorites/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ async def get_lifetime_prayer_stats(

cache_key = f"prayer-stats-{status}"

data = await cache.aget(cache_key)
if data is not None:
return PrayerStats(
prayer_count=data["count"],
distinct_count=data["num_distinct_purchases"],
total_cost=data["total_cost"],
)

prayer_by_status = Prayer.objects.filter(status=status)

prayer_count = await prayer_by_status.acount()
Expand Down

0 comments on commit 3a64767

Please sign in to comment.