mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-08 23:58:15 -05:00
Merge pull request #1617 from smilerz/fix_sqlite_search
remove unaccent from sqlite search
This commit is contained in:
@@ -89,7 +89,10 @@ class RecipeSearch():
|
|||||||
|
|
||||||
self._search_type = self._search_prefs.search or 'plain'
|
self._search_type = self._search_prefs.search or 'plain'
|
||||||
if self._string:
|
if self._string:
|
||||||
self._unaccent_include = self._search_prefs.unaccent.values_list('field', flat=True)
|
if self._postgres:
|
||||||
|
self._unaccent_include = self._search_prefs.unaccent.values_list('field', flat=True)
|
||||||
|
else:
|
||||||
|
self._unaccent_include = []
|
||||||
self._icontains_include = [x + '__unaccent' if x in self._unaccent_include else x for x in self._search_prefs.icontains.values_list('field', flat=True)]
|
self._icontains_include = [x + '__unaccent' if x in self._unaccent_include else x for x in self._search_prefs.icontains.values_list('field', flat=True)]
|
||||||
self._istartswith_include = [x + '__unaccent' if x in self._unaccent_include else x for x in self._search_prefs.istartswith.values_list('field', flat=True)]
|
self._istartswith_include = [x + '__unaccent' if x in self._unaccent_include else x for x in self._search_prefs.istartswith.values_list('field', flat=True)]
|
||||||
self._trigram_include = None
|
self._trigram_include = None
|
||||||
@@ -726,9 +729,8 @@ class RecipeFacet():
|
|||||||
return self.get_facets()
|
return self.get_facets()
|
||||||
|
|
||||||
def _recipe_count_queryset(self, field, depth=1, steplen=4):
|
def _recipe_count_queryset(self, field, depth=1, steplen=4):
|
||||||
return Recipe.objects.filter(**{f'{field}__path__startswith': OuterRef('path')}, id__in=self._recipe_list, space=self._request.space
|
return Recipe.objects.filter(**{f'{field}__path__startswith': OuterRef('path'), f'{field}__depth__gte': depth}, id__in=self._recipe_list, space=self._request.space
|
||||||
).values(child=Substr(f'{field}__path', 1, steplen*depth)
|
).annotate(count=Coalesce(Func('pk', function='Count'), 0)).values('count')
|
||||||
).annotate(count=Count('pk', distinct=True)).values('count')
|
|
||||||
|
|
||||||
def _keyword_queryset(self, queryset, keyword=None):
|
def _keyword_queryset(self, queryset, keyword=None):
|
||||||
depth = getattr(keyword, 'depth', 0) + 1
|
depth = getattr(keyword, 'depth', 0) + 1
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ webdavclient3==3.14.6
|
|||||||
whitenoise==5.3.0
|
whitenoise==5.3.0
|
||||||
icalendar==4.0.9
|
icalendar==4.0.9
|
||||||
pyyaml==6.0
|
pyyaml==6.0
|
||||||
|
uritemplate==4.1.1
|
||||||
beautifulsoup4==4.10.0
|
beautifulsoup4==4.10.0
|
||||||
microdata==0.8.0
|
microdata==0.8.0
|
||||||
Jinja2==3.0.3
|
Jinja2==3.0.3
|
||||||
|
|||||||
Reference in New Issue
Block a user