ActivityPub: Change ordering to `nulls last` in favorites query
authorlain <lain@soykaf.club>
Wed, 27 May 2020 07:46:12 +0000 (09:46 +0200)
committerlain <lain@soykaf.club>
Wed, 27 May 2020 07:46:12 +0000 (09:46 +0200)
This makes it use our existing index and speeds up the query.

lib/pleroma/web/activity_pub/activity_pub.ex

index 0fe71694a6b5bff29494a0e34f93601e0676e332..b8a2873d84b7a568fa0bec2237ede6a535164f25 100644 (file)
@@ -1158,7 +1158,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     |> Activity.with_joined_object()
     |> Object.with_joined_activity()
     |> select([_like, object, activity], %{activity | object: object})
-    |> order_by([like, _, _], desc: like.id)
+    |> order_by([like, _, _], desc_nulls_last: like.id)
     |> Pagination.fetch_paginated(
       Map.merge(params, %{"skip_order" => true}),
       pagination,