Skip to content

Conversation

himaniraghav3
Copy link
Collaborator

Adds await to emails being sent

CONNECT_NOTIFICATION_EVENT,
COPILOT_OPPORTUNITY_STATUS,
COPILOT_REQUEST_STATUS,
TEMPLATE_IDS, USER_ROLE } from '../../constants';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider formatting the import statement so that each constant is on a separate line for better readability, like the other constants in this block.

}))
.then(async (opportunity) => {
const roles = await util.getRolesByRoleName(USER_ROLE.TC_COPILOT, req.log, req.id);
const { subjects = [] } = await util.getRoleInfo(roles[0], req.log, req.id);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the await util.getRoleInfo(roles[0], req.log, req.id); call to manage potential promise rejections.

await Promise.all(notificationPromises);

// send email to notify via slack
sendNotification('Copilots', config.copilotsSlackEmail);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to sendNotification('Copilots', config.copilotsSlackEmail); is redundant here because it is already included in the notificationPromises array and awaited with Promise.all(notificationPromises);. Consider removing this line to avoid sending duplicate notifications.

}))
.then(async (opportunity) => {
// eslint-disable-next-line no-console
console.time('getRolesByRoleName');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using console.time for performance measurement in production code is not recommended. Consider using a more robust logging or monitoring solution.

console.time('getRolesByRoleName');
const roles = await util.getRolesByRoleName(USER_ROLE.TC_COPILOT, req.log, req.id);
// eslint-disable-next-line no-console
console.timeEnd('getRolesByRoleName');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using console.timeEnd for performance measurement in production code is not recommended. Consider using a more robust logging or monitoring solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant