From e14e812c2d54c10ea07cc53d27dd9321cb82f06a Mon Sep 17 00:00:00 2001 From: smilerz Date: Mon, 4 Oct 2021 16:18:21 -0500 Subject: [PATCH] a better fix --- cookbook/helper/recipe_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/helper/recipe_search.py b/cookbook/helper/recipe_search.py index 05f932cf1..d63dba0f4 100644 --- a/cookbook/helper/recipe_search.py +++ b/cookbook/helper/recipe_search.py @@ -61,7 +61,7 @@ def search_recipes(request, queryset, params): # return queryset.annotate(last_view=Max('viewlog__pk')).annotate(new=Case(When(pk__in=last_viewed_recipes, then=('last_view')), default=Value(0))).filter(new__gt=0).order_by('-new') # queryset that only annotates most recent view (higher pk = lastest view) - queryset = queryset.annotate(last_view=Max('viewlog__pk')).annotate(recent=Coalesce(When(pk__in=last_viewed_recipes, then=('last_view')), Value(0))) + queryset = queryset.annotate(recent=Coalesce(Max('viewlog__pk'), Value(0))) orderby += ['-recent'] # TODO create setting for default ordering - most cooked, rating,