From 8311e0cc2911a93e4e54e43bfbc40bf2de0b191b Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Thu, 13 Jun 2024 07:41:56 +0000 Subject: [PATCH] fix: show correct tab count --- packages/lib/server-only/document/get-stats.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/lib/server-only/document/get-stats.ts b/packages/lib/server-only/document/get-stats.ts index 7fa6dfc56..9eaf85a50 100644 --- a/packages/lib/server-only/document/get-stats.ts +++ b/packages/lib/server-only/document/get-stats.ts @@ -30,6 +30,8 @@ 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, @@ -155,7 +157,7 @@ const getCounts = async ({ user, createdAt }: GetCountsOption) => { userId: user.id, createdAt, deletedAt: { - not: null, + gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), }, }, }), @@ -264,6 +266,7 @@ const getTeamCounts = async (options: GetTeamCountsOption) => { }, } satisfies Prisma.DocumentGroupByArgs; + // TODO: fix this because its returning 0 always deletedCountsGroupByArgs = { by: ['status'], _count: { @@ -273,7 +276,7 @@ const getTeamCounts = async (options: GetTeamCountsOption) => { userId: userIdWhereClause, createdAt, deletedAt: { - not: null, + gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), }, }, } satisfies Prisma.DocumentGroupByArgs;