From 5cee51fac5b5feca7e85420861bf512169e499c7 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Mon, 18 Nov 2019 21:34:54 +0300 Subject: [PATCH] fix `order by` for fetch_favorites --- lib/pleroma/pagination.ex | 5 ++++- lib/pleroma/web/activity_pub/activity_pub.ex | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/pagination.ex b/lib/pleroma/pagination.ex index 243f1a329..6321c2600 100644 --- a/lib/pleroma/pagination.ex +++ b/lib/pleroma/pagination.ex @@ -78,7 +78,8 @@ defmodule Pleroma.Pagination do since_id: :string, max_id: :string, offset: :integer, - limit: :integer + limit: :integer, + skip_order: :boolean } params = @@ -103,6 +104,8 @@ defmodule Pleroma.Pagination do where(query, [{q, table_position(query, table_binding)}], q.id < ^max_id) end + defp restrict(query, :order, %{skip_order: true}, _), do: query + defp restrict(query, :order, %{min_id: _}, table_binding) do order_by( query, diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index e452278f0..f1ff0ee0d 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1067,7 +1067,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do |> Object.with_joined_activity() |> select([_like, object, activity], %{activity | object: object}) |> order_by([like, _, _], desc: like.updated_at) - |> Pagination.fetch_paginated(params, pagination, :object_activity) + |> Pagination.fetch_paginated( + Map.merge(params, %{"skip_order" => true}), + pagination, + :object_activity + ) end defp maybe_update_cc(activities, list_memberships, %User{ap_id: user_ap_id}) -- 2.45.2