Skip to content

Commit

Permalink
check status activities on comments count
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Ryo committed Apr 2, 2024
1 parent 3e833b7 commit c6eafa7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server/manager/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit c6eafa7

Please sign in to comment.