# Improves filter_show_all()

* improves performance for filter_show_all() in ShareableTableFilterMixin and CheckboxCompensationTableFilter by ~40%
This commit is contained in:
mpeltriaux 2023-02-22 09:44:35 +01:00
parent 6653269427
commit 799b97341a
2 changed files with 8 additions and 4 deletions

View File

@ -55,10 +55,12 @@ class CheckboxCompensationTableFilter(CheckboxTableFilter):
"""
if not value:
return queryset.filter(
user_teams = self.user.shared_teams
result = queryset.filter(
Q(intervention__users__in=[self.user]) | # requesting user has access
Q(intervention__teams__in=self.user.shared_teams)
Q(intervention__teams__in=user_teams)
).distinct()
return result
else:
return queryset

View File

@ -50,9 +50,11 @@ class ShareableTableFilterMixin(django_filters.FilterSet):
"""
if not value:
return queryset.filter(
user_teams = self.user.shared_teams
result = queryset.filter(
Q(users__in=[self.user]) | # requesting user has access
Q(teams__in=self.user.shared_teams)
Q(teams__in=user_teams)
).distinct()
return result
else:
return queryset