From 4909b94d78f10bcfec9b92964f4462dd82155832 Mon Sep 17 00:00:00 2001 From: contradiction29 Date: Sat, 31 Aug 2024 20:08:09 +0900 Subject: [PATCH] Fix: Update total count program for unboundedlikes --- app/modules/db.server.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/modules/db.server.ts b/app/modules/db.server.ts index e9a0907..0777950 100644 --- a/app/modules/db.server.ts +++ b/app/modules/db.server.ts @@ -799,7 +799,17 @@ export async function getFeedComments(pagingNumber: number, type: FeedPostType, } } if (type === "unboundedLikes"){ - const totalCount = await prisma.dimComments.count(); + const totalCountRaw = await prisma.$queryRaw` + with raw as ( + select post_id, count(post_id) from fct_comment_vote_history + where vote_type = 1 + group by post_id + having count(post_id) >= 1 + ) + select count(*) from raw; + ` as { count: bigint }[] + const totalCount = Number(totalCountRaw[0].count); + const commentIds = await prisma.fctCommentVoteHistory.groupBy({ by: ["commentId"], _count: { commentVoteId: true },