Skip to content

PM 2321 - submit copilot request fails#858

Closed
himaniraghav3 wants to merge 7 commits into
developfrom
PM-2321
Closed

PM 2321 - submit copilot request fails#858
himaniraghav3 wants to merge 7 commits into
developfrom
PM-2321

Conversation

@himaniraghav3

Copy link
Copy Markdown
Collaborator

Adds await to emails being sent

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

Copy link
Copy Markdown

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.

@@ -66,7 +70,7 @@ module.exports = (req, data, existingTransaction) => {
const { subjects = [] } = await util.getRoleInfo(roles[0], req.log, req.id);

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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