Use desc id to sort instead of desc inserted_at
authorRoger Braun <roger@rogerbraun.net>
Sun, 17 Sep 2017 09:16:08 +0000 (11:16 +0200)
committerRoger Braun <roger@rogerbraun.net>
Sun, 17 Sep 2017 09:16:08 +0000 (11:16 +0200)
Should mean the same and is indexed.

lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/utils.ex
lib/pleroma/web/ostatus/ostatus_controller.ex

index 2a8034457d0c9afe62cec2c6f412672e727447b8..c4f7f432c0b0d88cde005510ac4f4017245e3a5c 100644 (file)
@@ -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),
   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
 
     Repo.all(query)
   end
 
index ef58b88d203ca483995cba0e072ef6369b078583..4b8e6b690023ada758d551565820fd4174b21701 100644 (file)
@@ -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}),
     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
       limit: 1
     Repo.one(query)
   end
index 05acfd04bc0f3d5879b4a4c4e3b9d185e8676339..4e3fbb4f692f8be010ed7150c69102f406d26b4b 100644 (file)
@@ -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,
     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
 
     activities = query
     |> Repo.all