aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-05-27 13:45:14 +0000
committerrinpatch <rinpatch@sdf.org>2020-06-08 00:58:31 +0300
commit3687788cf2ab91f6f40f76f9a82c448c477b1fec (patch)
tree6aa8e806db14befcce403b6b0681603cbe6da3ef /lib
parentf10b40828fd5f1e4fc7c4ffa9deb543d6a18eb17 (diff)
downloadpleroma-3687788cf2ab91f6f40f76f9a82c448c477b1fec.tar.gz
Merge branch 'notification-fixes' into 'develop'
Notification performance fixes See merge request pleroma/pleroma!2595
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex17
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 556075fba..8c6887a6b 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -70,8 +70,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
)
)
@@ -195,7 +196,7 @@ defmodule Pleroma.Notification do
|> Repo.all()
end
- def set_read_up_to(%{id: user_id} = _user, id) do
+ def set_read_up_to(%{id: user_id} = user, id) do
query =
from(
n in Notification,
@@ -215,18 +216,8 @@ defmodule Pleroma.Notification do
{_, notification_ids} = Repo.update_all(query, [])
- 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