From 3eb51e9521427586ef7d6996f91d3e432948d172 Mon Sep 17 00:00:00 2001 From: Qurban Ahmad Date: Tue, 19 Nov 2024 22:50:12 +0530 Subject: [PATCH] refactor: reuse countUsersWithAnalytics and move count above users and use promise.all for multiple async method --- apps/api/src/app/admin/admin.service.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts index ab8fa3d57..d7510903e 100644 --- a/apps/api/src/app/admin/admin.service.ts +++ b/apps/api/src/app/admin/admin.service.ts @@ -140,7 +140,7 @@ export class AdminService { const [settings, transactionCount, userCount] = await Promise.all([ this.propertyService.get(), this.prismaService.order.count(), - this.prismaService.user.count() + this.countUsersWithAnalytics() ]); return { @@ -436,10 +436,11 @@ export class AdminService { skip?: number; take?: number; }): Promise { - return { - users: await this.getUsersWithAnalytics({ skip, take }), - count: await this.countUsersWithAnalytics() - }; + const [count, users] = await Promise.all([ + this.countUsersWithAnalytics(), + await this.getUsersWithAnalytics({ skip, take }) + ]); + return { count, users }; } public async patchAssetProfileData({