Preloading of follow relations for timeline/statuses rendering (performance improvement). Refactoring.

This commit is contained in:
Ivan Tashkinov 2020-03-23 12:01:11 +03:00
commit 3c78e5f327
5 changed files with 130 additions and 37 deletions

View file

@ -116,6 +116,19 @@ defmodule Pleroma.UserRelationship do
|> Repo.all()
end
def exists?(dictionary, rel_type, source, target, func) do
cond do
is_nil(source) or is_nil(target) ->
false
dictionary ->
[rel_type, source.id, target.id] in dictionary
true ->
func.(source, target)
end
end
defp validate_not_self_relationship(%Ecto.Changeset{} = changeset) do
changeset
|> validate_change(:target_id, fn _, target_id ->