Change blocking/blockers queries to use index

This commit is contained in:
Alex Gleason 2022-01-09 15:29:55 -06:00
parent 71baa713bc
commit 898c8fda4b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 4 additions and 4 deletions

View File

@ -138,7 +138,7 @@ defp exclude_blocked(query, user, opts) do
blocked_ap_ids = opts[:blocked_users_ap_ids] || User.blocked_users_ap_ids(user)
query
|> where([n, a], a.actor not in ^blocked_ap_ids)
|> where([n, a], fragment("not (? && ?)", [a.actor], ^blocked_ap_ids))
|> FollowingRelationship.keep_following_or_not_domain_blocked(user)
end
@ -149,7 +149,7 @@ defp exclude_blockers(query, user) do
blocker_ap_ids = User.incoming_relationships_ungrouped_ap_ids(user, [:block])
query
|> where([n, a], a.actor not in ^blocker_ap_ids)
|> where([n, a], fragment("not (? && ?)", [a.actor], ^blocker_ap_ids))
end
end

View File

@ -1035,7 +1035,7 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
from(
[activity, object: o] in query,
# You don't block the author
where: fragment("not (? = ANY(?))", activity.actor, ^blocked_ap_ids),
where: fragment("not (? && ?)", [activity.actor], ^blocked_ap_ids),
# You don't block any recipients, and didn't author the post
where:
@ -1099,7 +1099,7 @@ defp restrict_blockers_visibility(query, %{blocking_user: %User{} = user}) do
from(
activity in query,
# The author doesn't block you
where: fragment("not (? = ANY(?))", activity.actor, ^blocker_ap_ids),
where: fragment("not (? && ?)", [activity.actor], ^blocker_ap_ids),
# It's not a boost of a user that blocks you
where: