From 6a639c34a09fbda5300cf4cb7165c31ccee00f51 Mon Sep 17 00:00:00 2001 From: bhavanakarwade <137506897+bhavanakarwade@users.noreply.github.com> Date: Tue, 25 Jun 2024 20:03:17 +0530 Subject: [PATCH] refactor: get schemas by orgId response (#811) * feat: get w3c schema details by schema id Signed-off-by: bhavanakarwade * refactor: applied validations Signed-off-by: bhavanakarwade * refactor: get schemas by orgId response Signed-off-by: bhavanakarwade * refactor: optimized logic Signed-off-by: bhavanakarwade --------- Signed-off-by: bhavanakarwade --- .../src/schema/repositories/schema.repository.ts | 16 +++++++++++++++- apps/ledger/src/schema/schema.service.ts | 13 +++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/apps/ledger/src/schema/repositories/schema.repository.ts b/apps/ledger/src/schema/repositories/schema.repository.ts index b582acc8a..d8e4f3b68 100644 --- a/apps/ledger/src/schema/repositories/schema.repository.ts +++ b/apps/ledger/src/schema/repositories/schema.repository.ts @@ -88,7 +88,21 @@ export class SchemaRepository { createdBy: true, publisherDid: true, orgId: true, - issuerId: true + issuerId: true, + organisation: { + select:{ + name: true, + userOrgRoles: { + select: { + user: { + select: { + firstName: true + } + } + } + } + } + } }, orderBy: { [payload.sortField]: SortValue.ASC === payload.sortBy ? SortValue.ASC : SortValue.DESC diff --git a/apps/ledger/src/schema/schema.service.ts b/apps/ledger/src/schema/schema.service.ts index 962f11463..26470b420 100644 --- a/apps/ledger/src/schema/schema.service.ts +++ b/apps/ledger/src/schema/schema.service.ts @@ -763,8 +763,17 @@ export class SchemaService extends BaseService { const schemasDetails = response?.schemasResult.map(schemaAttributeItem => { const attributes = JSON.parse(schemaAttributeItem.attributes); - return {...schemaAttributeItem, attributes}; - }); + const firstName = schemaAttributeItem?.['organisation']?.userOrgRoles[0]?.user?.firstName; + const orgName = schemaAttributeItem?.['organisation'].name; + delete schemaAttributeItem?.['organisation']; + + return { + ...schemaAttributeItem, + attributes, + organizationName: orgName, + userName: firstName + }; + }); const nextPage:number = Number(schemaSearchCriteria.pageNumber) + 1;