exclude replies on blocked domains
This commit is contained in:
parent
fa37bfff99
commit
7e6ec778d9
9 changed files with 469 additions and 175 deletions
|
|
@ -36,6 +36,7 @@ defmodule Pleroma.LoadTesting.Fetcher do
|
|||
fetch_home_timeline(user)
|
||||
fetch_direct_timeline(user)
|
||||
fetch_public_timeline(user)
|
||||
fetch_public_timeline(user, :with_blocks)
|
||||
fetch_public_timeline(user, :local)
|
||||
fetch_public_timeline(user, :tag)
|
||||
fetch_notifications(user)
|
||||
|
|
@ -227,6 +228,76 @@ defmodule Pleroma.LoadTesting.Fetcher do
|
|||
fetch_public_timeline(opts, "public timeline only media")
|
||||
end
|
||||
|
||||
# TODO: remove using `:method` after benchmarks
|
||||
defp fetch_public_timeline(user, :with_blocks) do
|
||||
opts = opts_for_public_timeline(user)
|
||||
|
||||
remote_non_friends = Agent.get(:non_friends_remote, & &1)
|
||||
|
||||
Benchee.run(
|
||||
%{
|
||||
"public timeline without blocks" => fn opts ->
|
||||
ActivityPub.fetch_public_activities(opts)
|
||||
end
|
||||
},
|
||||
inputs: %{
|
||||
"old filtering" => Map.delete(opts, :method),
|
||||
"with psql fun" => Map.put(opts, :method, :fun),
|
||||
"with unnest" => Map.put(opts, :method, :unnest)
|
||||
}
|
||||
)
|
||||
|
||||
Enum.each(remote_non_friends, fn non_friend ->
|
||||
{:ok, _} = User.block(user, non_friend)
|
||||
end)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
opts = Map.put(opts, "blocking_user", user)
|
||||
|
||||
Benchee.run(
|
||||
%{
|
||||
"public timeline with user block" => fn opts ->
|
||||
ActivityPub.fetch_public_activities(opts)
|
||||
end
|
||||
},
|
||||
inputs: %{
|
||||
"old filtering" => Map.delete(opts, :method),
|
||||
"with psql fun" => Map.put(opts, :method, :fun),
|
||||
"with unnest" => Map.put(opts, :method, :unnest)
|
||||
}
|
||||
)
|
||||
|
||||
domains =
|
||||
Enum.reduce(remote_non_friends, [], fn non_friend, domains ->
|
||||
{:ok, _user} = User.unblock(user, non_friend)
|
||||
%{host: host} = URI.parse(non_friend.ap_id)
|
||||
[host | domains]
|
||||
end)
|
||||
|
||||
domains = Enum.uniq(domains)
|
||||
|
||||
Enum.each(domains, fn domain ->
|
||||
{:ok, _} = User.block_domain(user, domain)
|
||||
end)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
opts = Map.put(opts, "blocking_user", user)
|
||||
|
||||
Benchee.run(
|
||||
%{
|
||||
"public timeline with domain block" => fn opts ->
|
||||
ActivityPub.fetch_public_activities(opts)
|
||||
end
|
||||
},
|
||||
inputs: %{
|
||||
"old filtering" => Map.delete(opts, :method),
|
||||
"with psql fun" => Map.put(opts, :method, :fun),
|
||||
"with unnest" => Map.put(opts, :method, :unnest)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
defp fetch_public_timeline(opts, title) when is_binary(title) do
|
||||
first_page_last = ActivityPub.fetch_public_activities(opts) |> List.last()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue