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 @@ defmodule Pleroma.Activity do
end
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,
where:
fragment(
"? not in (SELECT ap_id FROM users WHERE info->'deactivated' @> 'true')",
activity.actor
)
where: activity.actor not in ^deactivated_users
)
end

View File

@ -796,7 +796,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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
query
end