def restrict_deactivated_users(query) do
query
- |> join(:inner, [activity], user in User, as: :user, on: activity.actor == user.ap_id and user.is_active == true)
+ |> join(:inner_lateral, [activity], active in fragment("SELECT is_active from users WHERE ap_id = ? AND is_active = TRUE", activity.actor))
end
defdelegate search(user, query, options \\ []), to: Pleroma.Search.DatabaseSearch
defp fetch_paginated_optimized(query, opts, pagination) do
# Note: tag-filtering funcs may apply "ORDER BY objects.id DESC",
# and extra sorting on "activities.id DESC NULLS LAST" would worse the query plan
- IO.inspect(Repo.to_sql(:all, query))
opts = Map.put(opts, :skip_extra_order, true)
Pagination.fetch_paginated(query, opts, pagination)