From 1cd6194deeca32a96a31fc43c0ed27daadd65f64 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 24 May 2018 12:44:26 +0200 Subject: More efficient queries. --- lib/pleroma/web/activity_pub/utils.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 937f032c3..a3feca480 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -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( -- cgit v1.2.3