Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: get schemas by orgId response #811

Merged
merged 7 commits into from
Jun 25, 2024
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
18 changes: 16 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,22 @@ 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;

return {
createDateTime: schemaAttributeItem.createDateTime,
name: schemaAttributeItem.name,
version: schemaAttributeItem.version,
attributes,
schemaLedgerId: schemaAttributeItem.schemaLedgerId,
createdBy: schemaAttributeItem.createdBy,
publisherDid: schemaAttributeItem.publisherDid,
orgId: schemaAttributeItem.orgId,
issuerId: schemaAttributeItem.issuerId,
organisationName: schemaAttributeItem?.['organisation'].name,
userName: firstName
};
bhavanakarwade marked this conversation as resolved.
Show resolved Hide resolved
});

const nextPage:number = Number(schemaSearchCriteria.pageNumber) + 1;

Expand Down