fix MakeNow filter

This commit is contained in:
Chris Scoggins 2022-02-03 17:19:38 -06:00
parent 6ef25b604b
commit f9244a93a5
No known key found for this signature in database
GPG Key ID: 41617A4206CCBAC6
2 changed files with 6 additions and 7 deletions

View File

@ -115,8 +115,9 @@ class RecipeSearch():
self.internal_filter() self.internal_filter()
self.step_filters(steps=self._steps) self.step_filters(steps=self._steps)
self.unit_filters(units=self._units) self.unit_filters(units=self._units)
self.string_filters(string=self._string)
self._makenow_filter() self._makenow_filter()
self.string_filters(string=self._string) # TODO this is overriding other filters!
return self._queryset.filter(space=self._request.space).distinct().order_by(*self.orderby) return self._queryset.filter(space=self._request.space).distinct().order_by(*self.orderby)
def _sort_includes(self, *args): def _sort_includes(self, *args):
@ -176,7 +177,7 @@ class RecipeSearch():
query_filter |= f query_filter |= f
else: else:
query_filter = f query_filter = f
self._queryset = self._queryset.filter(query_filter) self._queryset = self._queryset.filter(query_filter).distinct()
if self._fulltext_include: if self._fulltext_include:
if self._fuzzy_match is None: if self._fuzzy_match is None:
self._queryset = self._queryset.annotate(score=self.search_rank) self._queryset = self._queryset.annotate(score=self.search_rank)
@ -427,10 +428,9 @@ class RecipeSearch():
| Q(steps__ingredients__food__in=self.__sibling_substitute_filter(shopping_users)) | Q(steps__ingredients__food__in=self.__sibling_substitute_filter(shopping_users))
) )
self._queryset = self._queryset.annotate( self._queryset = self._queryset.annotate(
count_food=Count('steps__ingredients__food'), count_food=Count('steps__ingredients__food', filter=Q(steps__ingredients__food__ignore_shopping=False, steps__ingredients__food__isnull=False), distinct=True),
count_onhand=Count('pk', filter=Q(onhand_filter)), count_onhand=Count('pk', filter=onhand_filter)
count_ignore=Count('pk', filter=Q(steps__ingredients__food__ignore_shopping=True)) ).annotate(missingfood=F('count_food')-F('count_onhand')).filter(missingfood__lte=0)
).annotate(missingfood=F('count_food')-F('count_onhand')-F('count_ignore')).filter(missingfood=0)
@staticmethod @staticmethod
def __children_substitute_filter(shopping_users=None): def __children_substitute_filter(shopping_users=None):

View File

@ -1029,7 +1029,6 @@ export default {
if (!this.searchFiltered()) { if (!this.searchFiltered()) {
params.options.query.last_viewed = this.ui.recently_viewed params.options.query.last_viewed = this.ui.recently_viewed
} }
console.log(params)
return params return params
}, },
searchFiltered: function (ignore_string = false) { searchFiltered: function (ignore_string = false) {