Skip to content

feat(PM-1173): Notify all copilots on copilot opportunity #815

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

Merged
merged 23 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
deploy feature branch
  • Loading branch information
hentrymartin committed Jun 2, 2025
commit 82dd7978ff0607399c56cef81c3d30ec8d47d2e6
2 changes: 1 addition & 1 deletion src/routes/copilotRequest/approveRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = [
updatedBy: req.authUser.userId,
});

return approveRequest(data)
return approveRequest(req, data)
Copy link

Choose a reason for hiding this comment

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

The approveRequest function signature has changed to include req as a parameter. Ensure that the approveRequest function is updated to handle this new parameter correctly. If req is not needed in the function, consider removing it to maintain the original function signature.

.then(_newCopilotOpportunity => res.status(201).json(_newCopilotOpportunity))
.catch((err) => {
if (err.message) {
Expand Down
6 changes: 3 additions & 3 deletions src/routes/copilotRequest/approveRequest.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const resolveTransaction = (transaction, callback) => {
return models.sequelize.transaction(callback);
};

module.exports = (data, existingTransaction) => {
module.exports = (req, data, existingTransaction) => {
Copy link

Choose a reason for hiding this comment

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

The function signature has been changed to include req as a parameter. Ensure that req is used appropriately within the function. If req is not used, consider removing it to avoid confusion.

const { projectId, copilotRequestId } = data;

return resolveTransaction(existingTransaction, transaction =>
Expand Down Expand Up @@ -55,8 +55,8 @@ module.exports = (data, existingTransaction) => {
}))
Copy link

Choose a reason for hiding this comment

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

The console.log(opportunity); statement has been removed, which is good for production code, but ensure that any necessary logging is still in place for debugging purposes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason to use console here instead of the req.log?

.then(async (opportunity) => {
Copy link

Choose a reason for hiding this comment

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

Consider removing the console.log(opportunity); statement if it's not needed for debugging purposes. Leaving console logs in production code can lead to performance issues and cluttered logs.

console.log(opportunity);
Copy link

Choose a reason for hiding this comment

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

Avoid using console.log for debugging in production code. Consider using a logging library to handle logs appropriately.

const roles = await util.getRolesByRoleName('copilot');
const roleInfo = await util.getRoleInfo(roles[0]);
const roles = await util.getRolesByRoleName('copilot', 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.

The function getRolesByRoleName now takes additional parameters req.log and req.id. Ensure that req is defined and available in this context to avoid potential runtime errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Conver role name to enum/constant. Do not use hardcoded names.

const roleInfo = 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.

Similarly, the function getRoleInfo now takes additional parameters req.log and req.id. Verify that req is correctly passed and accessible here to prevent any issues.

console.log(roles, roleInfo, 'roles by copilot');
Copy link

Choose a reason for hiding this comment

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

Consider removing the console.log(roles, roleInfo, 'roles by copilot'); statement if it's not necessary for debugging. Console logs can clutter the output and should be avoided in production code.


return opportunity;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/copilotRequest/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = [
updatedBy: req.authUser.userId,
type: copilotRequest.data.projectType,
});
return approveRequest(approveData, transaction).then(() => copilotRequest);
return approveRequest(req, approveData, transaction).then(() => copilotRequest);
Copy link

Choose a reason for hiding this comment

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

The approveRequest function signature has changed to include req as an additional parameter. Ensure that the approveRequest function is updated accordingly to handle this new parameter, and verify that all calls to approveRequest throughout the codebase are updated to match this new signature.

}).then(copilotRequest => res.status(201).json(copilotRequest))
.catch((err) => {
try {
Expand Down