-
Notifications
You must be signed in to change notification settings - Fork 8
"added-targetedEntityTypes-field" #146
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
Conversation
priyanka-TL
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on May 30th 5.41 PM
priyanka-TL
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on May 30th 5.41 PM
priyanka-TL
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on May 30th 5.41 PM
priyanka-TL
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on May 30th 5.41 PM
src/module/entities/helper.js
Outdated
| childHierarchyPath = validatedChildHierarchy.map(String) | ||
| } | ||
|
|
||
| if (singleEntity['targetedEntityTypes']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Prajwal17Tunerlabs Can we optimize this
singleEntity.targetedEntityTypes = Array.isArray(singleEntity.targetedEntityTypes)
? await populateTargetedEntityTypesData(
singleEntity.targetedEntityTypes.map(item => item.trim()),
tenantId
)
: []
| return entityMetaInformation | ||
| } | ||
|
|
||
| async function populateTargetedEntityTypesData(targetedEntityTypes, tenantId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Prajwal17Tunerlabs add it in try catch also using object destructuring
somethin g like below
async function populateTargetedEntityTypesData(targetedEntityTypes, tenantId) {
try {
const entityTypes = await entityTypeQueries.entityTypesDocument(
{ name: { $in: targetedEntityTypes }, tenantId },
['name', '_id']
)
return entityTypes.map(({ _id, name }) => ({
entityTypeId: _id.toString(),
entityType: name,
}))
} catch (error) {
console.error('Error populating targeted entity types:', error)
return [] // or throw error if you want to bubble it up
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code updated as suggested
No description provided.