From: FloatingGhost Date: Mon, 10 Oct 2022 15:45:02 +0000 (+0100) Subject: Use inner lateral join to not get dropped in :total X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=ca9e6ffc554f7bf82cfb2c2093a0fcd283349f46;p=akkoma Use inner lateral join to not get dropped in :total --- diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index fef9aa874..12601b4af 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -369,7 +369,7 @@ defmodule Pleroma.Activity do 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 diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 7ed617823..dcdc7085f 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -507,7 +507,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do 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)