Use inner lateral join to not get dropped in :total
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Mon, 10 Oct 2022 15:45:02 +0000 (16:45 +0100)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Mon, 10 Oct 2022 15:45:02 +0000 (16:45 +0100)
lib/pleroma/activity.ex
lib/pleroma/web/activity_pub/activity_pub.ex

index fef9aa8743b0293b324ed7a2642d99f9853e78d2..12601b4af7ce6566e06d0ffb944be69152a3e7d5 100644 (file)
@@ -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
index 7ed6178232bb0153a337538040a7abd485dfb64d..dcdc7085fdaebc45eb36f4d279100ff33cce59a3 100644 (file)
@@ -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)