Merge branch 'master' into wallet-interface

This commit is contained in:
ekzyis 2024-07-15 13:24:38 +02:00
commit 6ac675429c
2 changed files with 5 additions and 4 deletions

View File

@ -200,15 +200,16 @@ export async function onPaid ({ invoice, id }, context) {
// denormalize ncomments, lastCommentAt, and "weightedComments" for ancestors, and insert into reply table // denormalize ncomments, lastCommentAt, and "weightedComments" for ancestors, and insert into reply table
await tx.$executeRaw` await tx.$executeRaw`
WITH comment AS ( WITH comment AS (
SELECT * SELECT "Item".*, users.trust
FROM "Item" FROM "Item"
WHERE id = ${item.id}::INTEGER JOIN users ON "Item"."userId" = users.id
WHERE "Item".id = ${item.id}::INTEGER
), ancestors AS ( ), ancestors AS (
UPDATE "Item" UPDATE "Item"
SET ncomments = "Item".ncomments + 1, SET ncomments = "Item".ncomments + 1,
"lastCommentAt" = now(), "lastCommentAt" = now(),
"weightedComments" = "Item"."weightedComments" + "weightedComments" = "Item"."weightedComments" +
CASE WHEN comment."userId" = "Item"."userId" THEN 0 ELSE ${item.user.trust}::FLOAT END CASE WHEN comment."userId" = "Item"."userId" THEN 0 ELSE comment.trust END
FROM comment FROM comment
WHERE "Item".path @> comment.path AND "Item".id <> comment.id WHERE "Item".path @> comment.path AND "Item".id <> comment.id
RETURNING "Item".* RETURNING "Item".*

View File

@ -1165,7 +1165,7 @@ export default {
FROM "Item" FROM "Item"
${whereClause( ${whereClause(
'"Item".id = $1', '"Item".id = $1',
`("Item"."invoiceActionState" IS NULL OR "Item"."invoiceActionState" = 'PAID' OR "Item"."userId" = ${me.id})` `("Item"."invoiceActionState" IS NULL OR "Item"."invoiceActionState" = 'PAID'${me ? ` OR "Item"."userId" = ${me.id}` : ''})`
)}` )}`
}, Number(item.rootId)) }, Number(item.rootId))