Browse Source

feat: added count response to the GET /api/v1/admin/user

pull/4058/head
Qurban Ahmad 9 months ago
parent
commit
c266d579ff
  1. 20
      apps/api/src/app/admin/admin.service.ts
  2. 1
      libs/common/src/lib/interfaces/admin-users.interface.ts

20
apps/api/src/app/admin/admin.service.ts

@ -436,7 +436,7 @@ export class AdminService {
skip?: number; skip?: number;
take?: number; take?: number;
}): Promise<AdminUsers> { }): Promise<AdminUsers> {
return { users: await this.getUsersWithAnalytics({ skip, take }) }; return { users: await this.getUsersWithAnalytics({ skip, take }), count: await this.countWithAnalytics() };
} }
public async patchAssetProfileData({ public async patchAssetProfileData({
@ -646,6 +646,24 @@ export class AdminService {
return { marketData, count: marketData.length }; return { marketData, count: marketData.length };
} }
private async countWithAnalytics(): Promise<number> {
let where: Prisma.UserWhereInput;
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
where = {
NOT: {
Analytics: null
}
};
}
const usersCountWithAnalytics = await this.prismaService.user.count({
where,
});
return usersCountWithAnalytics;
}
private async getUsersWithAnalytics({ private async getUsersWithAnalytics({
skip, skip,
take take

1
libs/common/src/lib/interfaces/admin-users.interface.ts

@ -11,4 +11,5 @@ export interface AdminUsers {
role: Role; role: Role;
transactionCount: number; transactionCount: number;
}[]; }[];
count: number;
} }

Loading…
Cancel
Save