Use a materialized Extension.latest_version field instead of a dynamic property #152

Merged
Oleg-Komarov merged 15 commits from latest-version-field into main 2024-05-27 17:58:56 +02:00
Showing only changes of commit b34648a8ad - Show all commits

View File

@ -76,7 +76,9 @@ class SearchView(ListedExtensionsView):
def get_queryset(self):
queryset = super().get_queryset()
if self.kwargs.get('tag_slug'):
queryset = queryset.filter(versions__tags__slug=self.kwargs['tag_slug']).distinct()
queryset = queryset.filter(
latest_version__tags__slug=self.kwargs['tag_slug']
).distinct()
if self.kwargs.get('team_slug'):
queryset = queryset.filter(team__slug=self.kwargs['team_slug'])
if self.kwargs.get('user_id'):
@ -94,7 +96,7 @@ class SearchView(ListedExtensionsView):
Q(slug__icontains=token)
| Q(name__icontains=token)
| Q(description__icontains=token)
| Q(versions__tags__name__icontains=token)
| Q(latest_version__tags__name__icontains=token)
)
queryset = queryset.filter(search_query).distinct()
return queryset.prefetch_related(