fixed performance issue

This commit is contained in:
vabene1111
2022-01-17 21:14:22 +01:00
parent 2595a26fb4
commit c8c29e1b5a

View File

@@ -647,7 +647,7 @@ class RecipeFacet():
depth = getattr(keyword, 'depth', 0) + 1
steplen = depth * Keyword.steplen
return queryset.annotate(count=Coalesce(Subquery(self._recipe_count_queryset('keywords', depth, steplen)), 0)
return queryset.annotate(count=Coalesce(1, 0)
).filter(depth=depth, count__gt=0
).values('id', 'name', 'count', 'numchild').order_by('name')
@@ -655,7 +655,7 @@ class RecipeFacet():
depth = getattr(food, 'depth', 0) + 1
steplen = depth * Food.steplen
return queryset.annotate(count=Coalesce(Subquery(self._recipe_count_queryset('steps__ingredients__food', depth, steplen)), 0)
return queryset.annotate(count=Coalesce(1, 0)
).filter(depth__lte=depth, count__gt=0
).values('id', 'name', 'count', 'numchild').order_by('name')