mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 16:24:23 +00:00
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
|
@ -240,11 +240,16 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
activity in Activity,
|
activity in Activity,
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"? @> ?",
|
"? ->> 'type' = 'Follow'",
|
||||||
activity.data,
|
activity.data
|
||||||
^%{type: "Follow", object: followed_id}
|
|
||||||
),
|
),
|
||||||
where: activity.actor == ^follower_id,
|
where: activity.actor == ^follower_id,
|
||||||
|
where:
|
||||||
|
fragment(
|
||||||
|
"? @> ?",
|
||||||
|
activity.data,
|
||||||
|
^%{object: followed_id}
|
||||||
|
),
|
||||||
order_by: [desc: :id],
|
order_by: [desc: :id],
|
||||||
limit: 1
|
limit: 1
|
||||||
)
|
)
|
||||||
|
@ -365,11 +370,16 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
activity in Activity,
|
activity in Activity,
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"? @> ?",
|
"? ->> 'type' = 'Block'",
|
||||||
activity.data,
|
activity.data
|
||||||
^%{type: "Block", object: blocked_id}
|
|
||||||
),
|
),
|
||||||
where: activity.actor == ^blocker_id,
|
where: activity.actor == ^blocker_id,
|
||||||
|
where:
|
||||||
|
fragment(
|
||||||
|
"? @> ?",
|
||||||
|
activity.data,
|
||||||
|
^%{object: blocked_id}
|
||||||
|
),
|
||||||
order_by: [desc: :id],
|
order_by: [desc: :id],
|
||||||
limit: 1
|
limit: 1
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
defmodule Pleroma.Web.CommonAPI.Test do
|
||||||
use Pleroma.DataCase
|
use Pleroma.DataCase
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue