Caches suggested books

This commit is contained in:
Mouse Reeve
2022-01-05 13:12:49 -08:00
parent 3cda27577f
commit ad6d7d5eca
5 changed files with 97 additions and 81 deletions

View File

@ -223,7 +223,6 @@ def feed_page_data(user):
goal = models.AnnualGoal.objects.filter(user=user, year=timezone.now().year).first()
return {
"suggested_books": get_suggested_books(user),
"goal": goal,
"goal_form": forms.GoalForm(),
}

View File

@ -47,10 +47,11 @@ class ReadingStatus(View):
return HttpResponseBadRequest()
# invalidate the template cache
cache_key = make_template_fragment_key(
"shelve_button", [request.user.id, book_id]
)
cache.delete(cache_key)
cache_keys = [
make_template_fragment_key("shelve_button", [request.user.id, book_id]),
make_template_fragment_key("suggested_books", [request.user.id]),
]
cache.delete_many(cache_keys)
desired_shelf = get_object_or_404(
models.Shelf, identifier=identifier, user=request.user