From c6eafa7691a1aecefa6a378a92bb4d3bbbbaebcd Mon Sep 17 00:00:00 2001 From: Neo-Ryo Date: Tue, 2 Apr 2024 09:32:28 +0200 Subject: [PATCH] check status activities on comments count --- server/manager/activity.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/manager/activity.ts b/server/manager/activity.ts index f5f36611e..3ea43e393 100644 --- a/server/manager/activity.ts +++ b/server/manager/activity.ts @@ -122,12 +122,21 @@ export const getActivities = async ({ }; export const getActivitiesCommentCount = async (ids: number[]): Promise<{ [key: number]: number }> => { - if (ids.length === 0) { + const publishedActivityies = await AppDataSource.getRepository(Activity).find({ + where: { + id: In(ids), + status: 0, + }, + select: { + id: true, + }, + }); + if (publishedActivityies.length === 0) { return {}; } const comments = await AppDataSource.getRepository(Comment).find({ where: { - activityId: In(ids), + activityId: In(publishedActivityies.map((a) => a.id)), }, }); return comments.reduce<{ [key: number]: number }>((acc, comment) => {