Skip to content

Commit

Permalink
avoid float in prisma template param
Browse files Browse the repository at this point in the history
  • Loading branch information
huumn committed Jul 14, 2024
1 parent e045c46 commit dd4806c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/paidAction/itemCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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".*
Expand Down

0 comments on commit dd4806c

Please sign in to comment.