forked from AkkomaGang/akkoma
Merge branch 'bugfix/follow-query-overhead' into 'develop'
activitypub utils: optimize block and follow activity lookup See merge request pleroma/pleroma!171
This commit is contained in:
commit
caae83e6d5
2 changed files with 17 additions and 7 deletions
|
@ -240,11 +240,16 @@ def fetch_latest_follow(%User{ap_id: follower_id}, %User{ap_id: followed_id}) do
|
|||
activity in Activity,
|
||||
where:
|
||||
fragment(
|
||||
"? @> ?",
|
||||
activity.data,
|
||||
^%{type: "Follow", object: followed_id}
|
||||
"? ->> 'type' = 'Follow'",
|
||||
activity.data
|
||||
),
|
||||
where: activity.actor == ^follower_id,
|
||||
where:
|
||||
fragment(
|
||||
"? @> ?",
|
||||
activity.data,
|
||||
^%{object: followed_id}
|
||||
),
|
||||
order_by: [desc: :id],
|
||||
limit: 1
|
||||
)
|
||||
|
@ -365,11 +370,16 @@ def fetch_latest_block(%User{ap_id: blocker_id}, %User{ap_id: blocked_id}) do
|
|||
activity in Activity,
|
||||
where:
|
||||
fragment(
|
||||
"? @> ?",
|
||||
activity.data,
|
||||
^%{type: "Block", object: blocked_id}
|
||||
"? ->> 'type' = 'Block'",
|
||||
activity.data
|
||||
),
|
||||
where: activity.actor == ^blocker_id,
|
||||
where:
|
||||
fragment(
|
||||
"? @> ?",
|
||||
activity.data,
|
||||
^%{object: blocked_id}
|
||||
),
|
||||
order_by: [desc: :id],
|
||||
limit: 1
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
||||
defmodule Pleroma.Web.CommonAPI.Test do
|
||||
use Pleroma.DataCase
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
|
|
Loading…
Reference in a new issue