More efficient queries.
authorlain <lain@soykaf.club>
Thu, 24 May 2018 10:44:26 +0000 (12:44 +0200)
committerlain <lain@soykaf.club>
Thu, 24 May 2018 10:44:26 +0000 (12:44 +0200)
lib/pleroma/web/activity_pub/utils.ex
test/support/factory.ex

index 937f032c35e12e78fd9e2938fc91957b3f3ae501..a3feca480ce01be877b937109e22a832b2af46c3 100644 (file)
@@ -242,8 +242,9 @@ defmodule Pleroma.Web.ActivityPub.Utils do
           fragment(
             "? @> ?",
             activity.data,
-            ^%{type: "Follow", actor: follower_id, object: followed_id}
+            ^%{type: "Follow", object: followed_id}
           ),
+        where: activity.actor == ^follower_id,
         order_by: [desc: :id],
         limit: 1
       )
@@ -260,7 +261,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
     query =
       from(
         activity in Activity,
-        where: fragment("(?)->>'actor' = ?", activity.data, ^actor),
+        where: activity.actor == ^actor,
         # this is to use the index
         where:
           fragment(
index 8e21e2562da62cc47ee5b34ccece059cbbed7ea0..b2e98c8d108e6e2ebc8c7047290760bd3a5d978d 100644 (file)
@@ -95,7 +95,8 @@ defmodule Pleroma.Factory do
     }
 
     %Pleroma.Activity{
-      data: data
+      data: data,
+      actor: follower.ap_id
     }
   end