Preloading of follow relations for timeline/statuses rendering (performance improvement). Refactoring.
This commit is contained in:
parent
c2e415143b
commit
3c78e5f327
5 changed files with 130 additions and 37 deletions
|
|
@ -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 ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue