From 1a55f4253b98194142c2a4b154d5569a3010a206 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Thu, 13 Jun 2024 12:57:23 +0000 Subject: [PATCH] fix: tab count for teams --- packages/lib/server-only/document/get-stats.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/lib/server-only/document/get-stats.ts b/packages/lib/server-only/document/get-stats.ts index 9eaf85a50..9b09ff12e 100644 --- a/packages/lib/server-only/document/get-stats.ts +++ b/packages/lib/server-only/document/get-stats.ts @@ -30,8 +30,6 @@ export const getStats = async ({ user, period, ...options }: GetStatsInput) => { ? getTeamCounts({ ...options.team, createdAt }) : getCounts({ user, createdAt })); - console.log(deletedCounts); - const stats: Record = { [ExtendedDocumentStatus.DRAFT]: 0, [ExtendedDocumentStatus.PENDING]: 0, @@ -266,7 +264,7 @@ const getTeamCounts = async (options: GetTeamCountsOption) => { }, } satisfies Prisma.DocumentGroupByArgs; - // TODO: fix this because its returning 0 always + // Deleted counts. deletedCountsGroupByArgs = { by: ['status'], _count: { @@ -275,6 +273,16 @@ const getTeamCounts = async (options: GetTeamCountsOption) => { where: { userId: userIdWhereClause, createdAt, + status: ExtendedDocumentStatus.COMPLETED, + Recipient: { + some: { + email: teamEmail, + signingStatus: SigningStatus.SIGNED, + documentDeletedAt: { + gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), + }, + }, + }, deletedAt: { gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), },