Skip to content
Snippets Groups Projects
Commit 9a06d9f6 authored by kaniini's avatar kaniini
Browse files

notification: preload child objects

parent 4cedf454
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ defmodule Pleroma.Notification do
alias Pleroma.Activity
alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.Pagination
alias Pleroma.Repo
alias Pleroma.User
......@@ -33,7 +34,10 @@ defmodule Pleroma.Notification do
Notification
|> where(user_id: ^user.id)
|> join(:inner, [n], activity in assoc(n, :activity))
|> preload(:activity)
|> join(:left, [n, a], object in Object,
on: fragment("(?->>'id') = COALESCE((? -> 'object'::text) ->> 'id'::text)", object.data, a.data)
)
|> preload([n, a, o], activity: {a, object: o})
end
def for_user(user, opts \\ %{}) do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment