From 79b831bea845167bfd56e0c925ad7d757df1fe91 Mon Sep 17 00:00:00 2001 From: Nishad Shirsat <103021375+nishad-ayanworks@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:21:55 +0530 Subject: [PATCH] refactor: ecosystem lead details included ecosystem dashboard (#156) * worked on the ecosystem lead details Signed-off-by: Nishad * removed the unnecessary code and comments Signed-off-by: Nishad --------- Signed-off-by: Nishad Signed-off-by: KulkarniShashank --- apps/ecosystem/src/ecosystem.repository.ts | 7 +----- apps/ecosystem/src/ecosystem.service.ts | 25 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/apps/ecosystem/src/ecosystem.repository.ts b/apps/ecosystem/src/ecosystem.repository.ts index 565fe35ed..4961d58a6 100644 --- a/apps/ecosystem/src/ecosystem.repository.ts +++ b/apps/ecosystem/src/ecosystem.repository.ts @@ -236,12 +236,7 @@ export class EcosystemRepository { } } - /** - * - * @returns Get ecosystem dashboard card count - */ - // eslint-disable-next-line camelcase - async getEcosystemDashboardDetails(ecosystemId: string): Promise<{ membersCount: number; endorsementsCount: number; ecosystemConfigData: ecosystem_config[] }> { + async getEcosystemDashboardDetails(ecosystemId: string): Promise<{membersCount: number; endorsementsCount: number}> { try { const membersCount = await this.getEcosystemMembersCount(ecosystemId); const endorsementsCount = await this.getEcosystemEndorsementsCount(ecosystemId); diff --git a/apps/ecosystem/src/ecosystem.service.ts b/apps/ecosystem/src/ecosystem.service.ts index 3755c9405..dcd997871 100644 --- a/apps/ecosystem/src/ecosystem.service.ts +++ b/apps/ecosystem/src/ecosystem.service.ts @@ -87,7 +87,30 @@ export class EcosystemService { */ async getEcosystemDashboardDetails(ecosystemId: string): Promise { try { - return await this.ecosystemRepository.getEcosystemDashboardDetails(ecosystemId); + const endorseMemberCount = await this.ecosystemRepository.getEcosystemDashboardDetails(ecosystemId); + + const query = { + ecosystemId, + ecosystemRole: { + name: EcosystemRoles.ECOSYSTEM_LEAD + } + }; + + const ecosystemDetails = await this.ecosystemRepository.fetchEcosystemOrg( + query + ); + + const dashboardDetails = { + ecosystem: ecosystemDetails['ecosystem'], + membersCount: endorseMemberCount.membersCount, + endorsementsCount: endorseMemberCount.endorsementsCount, + ecosystemLead:{ + role: ecosystemDetails['ecosystemRole']['name'], + orgName: ecosystemDetails['orgName'] + } + }; + + return dashboardDetails; } catch (error) { this.logger.error(`In ecosystem dashboard details : ${JSON.stringify(error)}`); throw new RpcException(error.response ? error.response : error);