ActivityPub: Change ordering to `nulls last` in favorites query
authorlain <lain@soykaf.club>
Wed, 27 May 2020 07:46:12 +0000 (09:46 +0200)
committerrinpatch <rinpatch@sdf.org>
Sun, 7 Jun 2020 22:19:57 +0000 (01:19 +0300)
This makes it use our existing index and speeds up the query.

lib/pleroma/web/activity_pub/activity_pub.ex

index c4f83f9e1a3cc8cd2e087db4c5020391f4586382..5ce91a8d32088628303342b671a6b315f2f0f4e2 100644 (file)
@@ -1318,7 +1318,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,