From 678dd4c8ec85c34e1fded7d48ee0ab26e9555aad Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 17 Sep 2017 11:16:08 +0200 Subject: [PATCH] Use desc id to sort instead of desc inserted_at Should mean the same and is indexed. --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- lib/pleroma/web/activity_pub/utils.ex | 2 +- lib/pleroma/web/ostatus/ostatus_controller.ex | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 2a8034457..c4f7f432c 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -97,7 +97,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do def fetch_activities_for_context(context) do query = from activity in Activity, where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context), - order_by: [desc: :inserted_at] + order_by: [desc: :id] Repo.all(query) end diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index ef58b88d2..4b8e6b690 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -152,7 +152,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do query = from activity in Activity, where: fragment("? @> ?", activity.data, ^%{type: "Follow", actor: follower_id, object: followed_id}), - order_by: [desc: :inserted_at], + order_by: [desc: :id], limit: 1 Repo.one(query) end diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 05acfd04b..4e3fbb4f6 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -21,7 +21,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do query = from activity in Activity, where: fragment("?->>'actor' = ?", activity.data, ^user.ap_id), limit: 20, - order_by: [desc: :inserted_at] + order_by: [desc: :id] activities = query |> Repo.all -- 2.45.2