More efficient followers query

This commit is contained in:
Mouse Reeve 2021-09-20 14:29:01 -07:00
parent 0a32fefd93
commit 22ead6ba46

View file

@ -77,7 +77,7 @@ def privacy_filter(viewer, queryset, privacy_levels=None, following_only=False):
elif "followers" in privacy_levels: elif "followers" in privacy_levels:
queryset = queryset.exclude( queryset = queryset.exclude(
~Q( # user isn't following and it isn't their own status ~Q( # user isn't following and it isn't their own status
Q(user__in=viewer.following.all()) | Q(user=viewer) Q(user__followers=viewer) | Q(user=viewer)
), ),
privacy="followers", # and the status is followers only privacy="followers", # and the status is followers only
) )