Merge branch 'main' into narl.io

This commit is contained in:
nvrl committed 2026-02-16 19:28:01 +01:00
commit 1976f9e1c2
2 files changed
+6 -3

No files matched your search

+2 -2
View File
@@ -18,12 +18,12 @@ class FlavorViewSet(viewsets.ModelViewSet):
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
def get_queryset(self):
return Flavor.objects.select_related('category').annotate(average_rating=Avg('ratings__score')).order_by('-average_rating')
return Flavor.objects.select_related('category').annotate(average_rating=Avg('ratings__score')).order_by('-average_rating').distinct()
@action(detail=False, methods=['get'], permission_classes=[permissions.AllowAny])
def search(self, request):
# Unpaginated list of all flavors for the search autocomplete
flavors = Flavor.objects.select_related('category').order_by('name')
flavors = Flavor.objects.select_related('category').order_by('name').distinct()
data = [
{
'id': f.id,
+4 -1
View File
@@ -88,7 +88,10 @@ const GlobalSearch = () => {
freeSolo
size="small"
options={options}
getOptionLabel={(option) => typeof option === 'string' ? option : (option.name || '')}
getOptionLabel={(option) => {
if (typeof option === 'string') return option;
return option.category_name ? `${option.name} (${option.category_name})` : (option.name || '');
}}
inputValue={query}
onInputChange={(_, newValue) => setQuery(typeof newValue === 'string' ? newValue : '')}
onChange={(_, newValue) => {