From 9145f290dccc041fb484cc68b10255433ce96517 Mon Sep 17 00:00:00 2001 From: keyan Date: Tue, 2 Jul 2024 09:26:40 -0500 Subject: [PATCH] fix lastCommentAt denorm --- api/paidAction/itemCreate.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/paidAction/itemCreate.js b/api/paidAction/itemCreate.js index f58490d3..28f9a236 100644 --- a/api/paidAction/itemCreate.js +++ b/api/paidAction/itemCreate.js @@ -197,7 +197,7 @@ export async function onPaid ({ invoice, id }, context) { // TODO: referals for boost if (item.parentId) { - // denormalize ncomments and "weightedComments" for ancestors, and insert into reply table + // denormalize ncomments, lastCommentAt, and "weightedComments" for ancestors, and insert into reply table await tx.$executeRaw` WITH comment AS ( SELECT * @@ -206,6 +206,7 @@ export async function onPaid ({ invoice, id }, context) { ), 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 FROM comment