mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-02-08 23:32:21 +00:00
Merge pull request #1007 from bookwyrm-social/suggested_user_logic
Fixes follower/following logic in suggested user annotations
This commit is contained in:
commit
30a6c035b8
2 changed files with 4 additions and 4 deletions
|
@ -219,7 +219,7 @@ class ViewsHelpers(TestCase):
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
# 1 shared follow
|
# 1 shared follow
|
||||||
self.local_user.following.add(user_2)
|
self.local_user.following.add(user_2)
|
||||||
user_1.following.add(user_2)
|
user_1.followers.add(user_2)
|
||||||
|
|
||||||
# 1 shared book
|
# 1 shared book
|
||||||
models.ShelfBook.objects.create(
|
models.ShelfBook.objects.create(
|
||||||
|
@ -264,7 +264,7 @@ class ViewsHelpers(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname=i,
|
localname=i,
|
||||||
)
|
)
|
||||||
user.followers.add(user_1)
|
user.following.add(user_1)
|
||||||
user.followers.add(self.local_user)
|
user.followers.add(self.local_user)
|
||||||
|
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
|
|
|
@ -190,11 +190,11 @@ def get_annotated_users(user, *args, **kwargs):
|
||||||
.exclude(Q(id__in=user.blocks.all()) | Q(blocks=user))
|
.exclude(Q(id__in=user.blocks.all()) | Q(blocks=user))
|
||||||
.annotate(
|
.annotate(
|
||||||
mutuals=Count(
|
mutuals=Count(
|
||||||
"following",
|
"followers",
|
||||||
filter=Q(
|
filter=Q(
|
||||||
~Q(id=user.id),
|
~Q(id=user.id),
|
||||||
~Q(id__in=user.following.all()),
|
~Q(id__in=user.following.all()),
|
||||||
following__in=user.following.all(),
|
followers__in=user.following.all(),
|
||||||
),
|
),
|
||||||
distinct=True,
|
distinct=True,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue