diff options
author | lain <lain@soykaf.club> | 2018-05-24 12:44:26 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2018-05-24 12:44:26 +0200 |
commit | 1cd6194deeca32a96a31fc43c0ed27daadd65f64 (patch) | |
tree | d4408133a437cf29e680558a8e75689744b4b027 | |
parent | 0b5bc62b33a655488afe73b35945adcbab11300d (diff) | |
download | pleroma-1cd6194deeca32a96a31fc43c0ed27daadd65f64.tar.gz |
More efficient queries.
-rw-r--r-- | lib/pleroma/web/activity_pub/utils.ex | 5 | ||||
-rw-r--r-- | test/support/factory.ex | 3 |
2 files changed, 5 insertions, 3 deletions
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( diff --git a/test/support/factory.ex b/test/support/factory.ex index 8e21e2562..b2e98c8d1 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -95,7 +95,8 @@ defmodule Pleroma.Factory do } %Pleroma.Activity{ - data: data + data: data, + actor: follower.ap_id } end |