PM 2321 - submit copilot request fails#858
Conversation
| CONNECT_NOTIFICATION_EVENT, | ||
| COPILOT_OPPORTUNITY_STATUS, | ||
| COPILOT_REQUEST_STATUS, | ||
| TEMPLATE_IDS, USER_ROLE } from '../../constants'; |
There was a problem hiding this comment.
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); | |||
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
Using console.timeEnd for performance measurement in production code is not recommended. Consider using a more robust logging or monitoring solution.
Adds await to emails being sent