cleanup
This commit is contained in:
parent
f02a36b758
commit
432886c86c
|
@ -1,4 +1,5 @@
|
|||
defmodule Backend.FederationRestriction do
|
||||
@moduledoc false
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
|
|
|
@ -192,23 +192,10 @@ defmodule Backend.Scheduler do
|
|||
interactions
|
||||
|> reduce_mention_count(federation_blocks)
|
||||
|
||||
Logger.info(inspect(mentions))
|
||||
|
||||
# Filter down to mentions where there are interactions in both directions
|
||||
filtered_mentions =
|
||||
mentions
|
||||
|> Enum.filter(fn {{source_domain, target_domain}, {mention_count, _statuses_seen}} ->
|
||||
other_direction_key = {target_domain, source_domain}
|
||||
|
||||
if mention_count > 0 and Map.has_key?(mentions, other_direction_key) do
|
||||
{other_direction_mentions, _other_statuses_seen} =
|
||||
Map.get(mentions, other_direction_key)
|
||||
|
||||
other_direction_mentions > 0
|
||||
else
|
||||
false
|
||||
end
|
||||
end)
|
||||
|> Enum.filter(&has_opposite_mention?(&1, mentions))
|
||||
|
||||
edges =
|
||||
filtered_mentions
|
||||
|
@ -302,12 +289,46 @@ defmodule Backend.Scheduler do
|
|||
|
||||
statuses_seen = source_statuses_seen + target_statuses_seen
|
||||
|
||||
if not MapSet.member?(federation_blocks, {source_domain, target_domain}) and
|
||||
not MapSet.member?(federation_blocks, {target_domain, source_domain}) do
|
||||
Map.update(acc, key, {mentions, statuses_seen}, fn {curr_mentions, curr_statuses_seen} ->
|
||||
{curr_mentions + mentions, curr_statuses_seen}
|
||||
end)
|
||||
end
|
||||
maybe_update_map(
|
||||
acc,
|
||||
key,
|
||||
source_domain,
|
||||
target_domain,
|
||||
mentions,
|
||||
statuses_seen,
|
||||
federation_blocks
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
defp maybe_update_map(
|
||||
acc,
|
||||
key,
|
||||
source_domain,
|
||||
target_domain,
|
||||
mentions,
|
||||
statuses_seen,
|
||||
federation_blocks
|
||||
) do
|
||||
if not MapSet.member?(federation_blocks, {source_domain, target_domain}) and
|
||||
not MapSet.member?(federation_blocks, {target_domain, source_domain}) do
|
||||
Map.update(acc, key, {mentions, statuses_seen}, fn {curr_mentions, curr_statuses_seen} ->
|
||||
{curr_mentions + mentions, curr_statuses_seen}
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
defp has_opposite_mention?(mention, all_mentions) do
|
||||
{{source_domain, target_domain}, {mention_count, _statuses_seen}} = mention
|
||||
other_direction_key = {target_domain, source_domain}
|
||||
|
||||
if mention_count > 0 and Map.has_key?(all_mentions, other_direction_key) do
|
||||
{other_direction_mentions, _other_statuses_seen} =
|
||||
Map.get(all_mentions, other_direction_key)
|
||||
|
||||
other_direction_mentions > 0
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue