Commit 1cd6194d authored by lain's avatar lain
Browse files

More efficient queries.

parent 0b5bc62b
Pipeline #2020 passed with stages
in 4 minutes and 39 seconds
......@@ -242,8 +242,9 @@ def fetch_latest_follow(%User{ap_id: follower_id}, %User{ap_id: followed_id}) 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 @@ def get_existing_announce(actor, %{data: %{"id" => id}}) do
query =
from(
activity in Activity,
where: fragment("(?)->>'actor' = ?", activity.data, ^actor),
where: activity.actor == ^actor,
# this is to use the index
where:
fragment(
......
......@@ -95,7 +95,8 @@ def follow_activity_factory do
}
%Pleroma.Activity{
data: data
data: data,
actor: follower.ap_id
}
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment