Skip to content

Commit

Permalink
hotfix: avoid subquery when we already have a JOIN
Browse files Browse the repository at this point in the history
  • Loading branch information
Soxasora committed Feb 10, 2025
1 parent 8ec01f3 commit 6505de2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webPush.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const notifyItemParents = async ({ models, item }) => {
try {
const user = await models.user.findUnique({ where: { id: item.userId } })
const parents = await models.$queryRawUnsafe(
'SELECT DISTINCT p."userId", (SELECT "userId" FROM "Item" WHERE id = $1) = p."userId" as "isDirect" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2 ' +
'SELECT DISTINCT p."userId", i."userId" = p."userId" as "isDirect" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2 ' +
'AND NOT EXISTS (SELECT 1 FROM "Mute" m WHERE m."muterId" = p."userId" AND m."mutedId" = $2)',
Number(item.parentId), Number(user.id))
Promise.allSettled(
Expand Down

0 comments on commit 6505de2

Please sign in to comment.