Merge pull request #1007 from bookwyrm-social/suggested_user_logic

Fixes follower/following logic in suggested user annotations
This commit is contained in:
Mouse Reeve 2021-04-29 14:08:47 -07:00 committed by GitHub
commit 30a6c035b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -219,7 +219,7 @@ class ViewsHelpers(TestCase):
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
# 1 shared follow
self.local_user.following.add(user_2)
user_1.following.add(user_2)
user_1.followers.add(user_2)
# 1 shared book
models.ShelfBook.objects.create(
@ -264,7 +264,7 @@ class ViewsHelpers(TestCase):
local=True,
localname=i,
)
user.followers.add(user_1)
user.following.add(user_1)
user.followers.add(self.local_user)
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):

View file

@ -190,11 +190,11 @@ def get_annotated_users(user, *args, **kwargs):
.exclude(Q(id__in=user.blocks.all()) | Q(blocks=user))
.annotate(
mutuals=Count(
"following",
"followers",
filter=Q(
~Q(id=user.id),
~Q(id__in=user.following.all()),
following__in=user.following.all(),
followers__in=user.following.all(),
),
distinct=True,
),