aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2019-04-02 18:43:48 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2019-04-02 18:43:48 +0000
commit0cb94cfa945632e2a1825bb64fe4036ebbf22001 (patch)
tree5085193dd78affc1b570a5494016f0568d607ed5 /lib
parent256b492a5855c09f45af0325a9e9cd2508c88366 (diff)
parent39bcf93007a5a52ba374099d6b04692361e7fa9b (diff)
downloadpleroma-0cb94cfa945632e2a1825bb64fe4036ebbf22001.tar.gz
Merge branch 'fix-slow-relationships' into 'develop'
ActivityPub Utils: Greatly speed up the follow / block activity fetching. See merge request pleroma/pleroma!1011
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index 81e17b9c1..32545937e 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -423,13 +423,15 @@ defmodule Pleroma.Web.ActivityPub.Utils do
activity.data
),
where: activity.actor == ^follower_id,
+ # this is to use the index
where:
fragment(
- "? @> ?",
+ "coalesce((?)->'object'->>'id', (?)->>'object') = ?",
+ activity.data,
activity.data,
- ^%{object: followed_id}
+ ^followed_id
),
- order_by: [desc: :id],
+ order_by: [fragment("? desc nulls last", activity.id)],
limit: 1
)
@@ -586,13 +588,15 @@ defmodule Pleroma.Web.ActivityPub.Utils do
activity.data
),
where: activity.actor == ^blocker_id,
+ # this is to use the index
where:
fragment(
- "? @> ?",
+ "coalesce((?)->'object'->>'id', (?)->>'object') = ?",
+ activity.data,
activity.data,
- ^%{object: blocked_id}
+ ^blocked_id
),
- order_by: [desc: :id],
+ order_by: [fragment("? desc nulls last", activity.id)],
limit: 1
)