Merge branch 'chore/query-optimization' into 'develop'

chore: query optimization

Closes #1224

See merge request pleroma/pleroma!1640
This commit is contained in:
kaniini 2019-09-06 23:25:30 +00:00
commit c45013df8e
2 changed files with 6 additions and 6 deletions

View file

@ -362,12 +362,12 @@ def query_by_actor(actor) do
end end
def restrict_deactivated_users(query) do def restrict_deactivated_users(query) do
deactivated_users =
from(u in User.Query.build(deactivated: true), select: u.ap_id)
|> Repo.all()
from(activity in query, from(activity in query,
where: where: activity.actor not in ^deactivated_users
fragment(
"? not in (SELECT ap_id FROM users WHERE info->'deactivated' @> 'true')",
activity.actor
)
) )
end end

View file

@ -796,7 +796,7 @@ defp restrict_muted(query, %{"muting_user" => %User{info: info}} = opts) do
) )
unless opts["skip_preload"] do unless opts["skip_preload"] do
from([thread_mute: tm] in query, where: is_nil(tm)) from([thread_mute: tm] in query, where: is_nil(tm.user_id))
else else
query query
end end