diff options
author | lain <lain@soykaf.club> | 2020-05-27 12:41:06 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-27 12:41:06 +0200 |
commit | b8e029b5ea33c9267ac26ab7ba598f1cd7be46c2 (patch) | |
tree | a8596441ba9ee8448a7fc1fd0e4ee1a0975ed944 /lib | |
parent | 644195e31e500e96f60ab83ffb5f082a94c1123a (diff) | |
download | pleroma-b8e029b5ea33c9267ac26ab7ba598f1cd7be46c2.tar.gz |
Notification: Actually preload objects.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/notification.ex | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 8aa9ed2d4..fb16ec896 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -92,8 +92,9 @@ defmodule Pleroma.Notification do |> join(:left, [n, a], object in Object, on: fragment( - "(?->>'id') = COALESCE((? -> 'object'::text) ->> 'id'::text)", + "(?->>'id') = COALESCE(?->'object'->>'id', ?->>'object')", object.data, + a.data, a.data ) ) @@ -224,18 +225,8 @@ defmodule Pleroma.Notification do |> Marker.multi_set_last_read_id(user, "notifications") |> Repo.transaction() - Notification + for_user_query(user) |> where([n], n.id in ^notification_ids) - |> join(:inner, [n], activity in assoc(n, :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}) |> Repo.all() end |