From e1c54b2933bbfab278a2d49a5716911903f4385e Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Thu, 4 Apr 2024 13:47:51 +0200 Subject: [PATCH] Remove optimizations with adverse effects `if not audience` actually causes the entire query to be evaluated, before .values_list() is called. --- bookwyrm/activitystreams.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index b8f4ed985..0009ac7a3 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -183,8 +183,6 @@ class HomeStream(ActivityStream): def get_audience(self, status): trace.get_current_span().set_attribute("stream_id", self.key) audience = super()._get_audience(status) - if not audience: - return [] # if the user is following the author audience = audience.filter(following=status.user).values_list("id", flat=True) # if the user is the post's author @@ -239,9 +237,7 @@ class BooksStream(ActivityStream): ) audience = super()._get_audience(status) - if not audience: - return models.User.objects.none() - return audience.filter(shelfbook__book__parent_work=work).distinct() + return audience.filter(shelfbook__book__parent_work=work) def get_audience(self, status): # only show public statuses on the books feed,