mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-10 08:38:34 -05:00
optimized recipe search query annotation performance
This commit is contained in:
@@ -115,6 +115,10 @@ class RecipeSearch():
|
||||
|
||||
def get_queryset(self, queryset):
|
||||
self._queryset = queryset
|
||||
self._queryset = self._queryset.prefetch_related('keywords')
|
||||
self._queryset = self._queryset.annotate(rating=Avg('cooklog__rating'))
|
||||
self._queryset = self._queryset.annotate(last_cooked=Max('cooklog__created_at'))
|
||||
|
||||
self._build_sort_order()
|
||||
self._recently_viewed(num_recent=self._num_recent)
|
||||
self._cooked_on_filter(cooked_date=self._cookedon)
|
||||
|
||||
Reference in New Issue
Block a user