Skip to content

fix(PM-1494): Add extra info for copilot email #830

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 14 commits into from
Jul 23, 2025
Merged
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ workflows:
context : org-global
filters:
branches:
only: ['develop', 'migration-setup', 'pm-1368']
only: ['develop', 'migration-setup', 'pm-1494']
- deployProd:
context : org-global
filters:
Expand Down
9 changes: 7 additions & 2 deletions src/routes/copilotRequest/approveRequest.service.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import _ from 'lodash';
import config from 'config';
import moment from 'moment';
import { Op } from 'sequelize';

Choose a reason for hiding this comment

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

The import statement for Op from 'sequelize' has been moved but not modified. Consider reverting the change if it was unintentional, as it does not affect functionality.


import models from '../../models';
import { CONNECT_NOTIFICATION_EVENT, COPILOT_REQUEST_STATUS, TEMPLATE_IDS, USER_ROLE } from '../../constants';
import util from '../../util';
import { createEvent } from '../../services/busApi';
import { Op } from 'sequelize';
import { getCopilotTypeLabel } from '../../utils/copilot';

const resolveTransaction = (transaction, callback) => {
if (transaction) {
Expand All @@ -16,7 +18,7 @@ const resolveTransaction = (transaction, callback) => {
};

module.exports = (req, data, existingTransaction) => {
const { projectId, copilotRequestId } = data;
const { projectId, copilotRequestId, opportunityTitle, type, startDate } = data;

return resolveTransaction(existingTransaction, transaction =>
models.Project.findOne({
Expand Down Expand Up @@ -71,6 +73,9 @@ module.exports = (req, data, existingTransaction) => {
user_name: subject.handle,
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}`,
work_manager_url: config.get('workManagerUrl'),
opportunity_type: getCopilotTypeLabel(type),

Choose a reason for hiding this comment

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

The variable type is used here, but it is not clear from the diff if type is defined or correctly assigned a value. Ensure that type is defined and holds the expected value before using it in getCopilotTypeLabel(type).

opportunity_title: opportunityTitle,

Choose a reason for hiding this comment

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

The variable opportunityTitle is used here, but it is not clear from the diff if opportunityTitle is defined or correctly assigned a value. Ensure that opportunityTitle is defined and holds the expected value before using it.

start_date: moment.utc(startDate).format("YYYY-MM-DD HH:mm:ss [UTC]"),

Choose a reason for hiding this comment

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

The date format has been changed from DD-MM-YYYY h:mm:ss a to YYYY-MM-DD HH:mm:ss [UTC]. Ensure that this new format is compatible with all systems and services that consume this data, as it may affect parsing or display logic.

},
sendgrid_template_id: TEMPLATE_IDS.CREATE_REQUEST,
recipients: [subject.email],
Expand Down
2 changes: 2 additions & 0 deletions src/routes/copilotRequest/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ module.exports = [
createdBy: req.authUser.userId,
updatedBy: req.authUser.userId,
type: copilotRequest.data.projectType,
opportunityTitle: copilotRequest.data.opportunityTitle,

Choose a reason for hiding this comment

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

Ensure that copilotRequest.data.opportunityTitle is always defined and valid before using it here. Consider adding validation or a default value to prevent potential errors if opportunityTitle is missing or undefined.

startDate: copilotRequest.data.startDate,

Choose a reason for hiding this comment

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

Ensure that copilotRequest.data.startDate is properly validated and sanitized before being used here to prevent potential security issues or data inconsistencies.

});
return approveRequest(req, approveData, transaction).then(() => copilotRequest);
}).then(copilotRequest => res.status(201).json(copilotRequest))
Expand Down
16 changes: 16 additions & 0 deletions src/utils/copilot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { COPILOT_OPPORTUNITY_TYPE } from "../constants";

export const getCopilotTypeLabel = (type) => {
switch (type) {
case COPILOT_OPPORTUNITY_TYPE.AI:
return 'AI';
case COPILOT_OPPORTUNITY_TYPE.DATA_SCIENCE:
return "Data Science";
case COPILOT_OPPORTUNITY_TYPE.DESIGN:
return "Design";
case COPILOT_OPPORTUNITY_TYPE.DEV:
return "Development";
default:
return "Quality Assurance";
}
};