Skip to content

Commit

Permalink
refactor: get schemas by orgId response (#811)
Browse files Browse the repository at this point in the history
* feat: get w3c schema details by schema id

Signed-off-by: bhavanakarwade <bhavana.karwade@ayanworks.com>

* refactor: applied validations

Signed-off-by: bhavanakarwade <bhavana.karwade@ayanworks.com>

* refactor: get schemas by orgId response

Signed-off-by: bhavanakarwade <bhavana.karwade@ayanworks.com>

* refactor: optimized logic

Signed-off-by: bhavanakarwade <bhavana.karwade@ayanworks.com>

---------

Signed-off-by: bhavanakarwade <bhavana.karwade@ayanworks.com>
  • Loading branch information
bhavanakarwade authored and KulkarniShashank committed Sep 11, 2024
1 parent 7906c21 commit 6a639c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
16 changes: 15 additions & 1 deletion apps/ledger/src/schema/repositories/schema.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions apps/ledger/src/schema/schema.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6a639c3

Please sign in to comment.