fix: get correct count for team members in slider (#12017)

pull/11993/head
sean-brydon 2023-10-20 13:42:49 +01:00 committed by GitHub
parent 19eced00f5
commit be1517facd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import { Prisma } from "@prisma/client";
import type { Dayjs } from "@calcom/dayjs";
import dayjs from "@calcom/dayjs";
import type { DateRange } from "@calcom/lib/date-ranges";
@ -120,9 +122,16 @@ async function getInfoForAllTeams({ ctx, input }: GetOptions) {
limit,
});
// Get total team count across all teams the user is in (for pagination)
const totalTeamMembers =
await prisma.$queryRaw<number>`SELECT COUNT(DISTINCT "userId")::integer from "Membership" WHERE "teamId" IN (${Prisma.join(
teamIds
)})`;
return {
teamMembers,
totalTeamMembers: teamMembers.length,
totalTeamMembers,
};
}