Merge branch 'master' into wallet-interface
This commit is contained in:
commit
6ac675429c
|
@ -200,15 +200,16 @@ export async function onPaid ({ invoice, id }, context) {
|
|||
// denormalize ncomments, lastCommentAt, and "weightedComments" for ancestors, and insert into reply table
|
||||
await tx.$executeRaw`
|
||||
WITH comment AS (
|
||||
SELECT *
|
||||
SELECT "Item".*, users.trust
|
||||
FROM "Item"
|
||||
WHERE id = ${item.id}::INTEGER
|
||||
JOIN users ON "Item"."userId" = users.id
|
||||
WHERE "Item".id = ${item.id}::INTEGER
|
||||
), ancestors AS (
|
||||
UPDATE "Item"
|
||||
SET ncomments = "Item".ncomments + 1,
|
||||
"lastCommentAt" = now(),
|
||||
"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
|
||||
WHERE "Item".path @> comment.path AND "Item".id <> comment.id
|
||||
RETURNING "Item".*
|
||||
|
|
|
@ -1165,7 +1165,7 @@ export default {
|
|||
FROM "Item"
|
||||
${whereClause(
|
||||
'"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))
|
||||
|
||||
|
|
Loading…
Reference in New Issue