From 6bcc6f66cac2f8b3213e74a76606afbd1c8b5100 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Tue, 7 Oct 2025 16:14:09 +0530 Subject: [PATCH 1/7] await copilot emails --- .../copilotRequest/approveRequest.service.js | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/routes/copilotRequest/approveRequest.service.js b/src/routes/copilotRequest/approveRequest.service.js index 5ef4d2c12..363820dc1 100644 --- a/src/routes/copilotRequest/approveRequest.service.js +++ b/src/routes/copilotRequest/approveRequest.service.js @@ -4,7 +4,11 @@ import moment from 'moment'; import { Op } from 'sequelize'; import models from '../../models'; -import { CONNECT_NOTIFICATION_EVENT, COPILOT_OPPORTUNITY_STATUS, COPILOT_REQUEST_STATUS, TEMPLATE_IDS, USER_ROLE } from '../../constants'; +import { + CONNECT_NOTIFICATION_EVENT, + COPILOT_OPPORTUNITY_STATUS, + COPILOT_REQUEST_STATUS, + TEMPLATE_IDS, USER_ROLE } from '../../constants'; import util from '../../util'; import { createEvent } from '../../services/busApi'; import { getCopilotTypeLabel } from '../../utils/copilot'; @@ -47,7 +51,7 @@ module.exports = (req, data, existingTransaction) => { type: data.type, status: { [Op.in]: [COPILOT_OPPORTUNITY_STATUS.ACTIVE], - } + }, }, }) .then((existingCopilotOpportunityOfSameType) => { @@ -66,7 +70,7 @@ module.exports = (req, data, existingTransaction) => { const { subjects = [] } = await util.getRoleInfo(roles[0], req.log, req.id); const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_EMAIL; const copilotPortalUrl = config.get('copilotPortalUrl'); - req.log.info("Sending emails to all copilots about new opportunity"); + req.log.info('Sending emails to all copilots about new opportunity'); const sendNotification = (userName, recipient) => createEvent(emailEventType, { data: { @@ -75,20 +79,28 @@ module.exports = (req, data, existingTransaction) => { work_manager_url: config.get('workManagerUrl'), opportunity_type: getCopilotTypeLabel(type), opportunity_title: opportunityTitle, - start_date: moment(startDate).format("DD-MM-YYYY"), + start_date: moment(startDate).format('DD-MM-YYYY'), }, sendgrid_template_id: TEMPLATE_IDS.CREATE_REQUEST, recipients: [recipient], version: 'v3', }, req.log); - subjects.forEach(subject => sendNotification(subject.handle, subject.email)); + const notificationPromises = subjects.map(subject => + sendNotification(subject.handle, subject.email), + ); + + notificationPromises.push( + sendNotification('Copilots', config.copilotsSlackEmail), + ); + + await Promise.all(notificationPromises); // send email to notify via slack sendNotification('Copilots', config.copilotsSlackEmail); - req.log.info("Finished sending emails to copilots"); - + req.log.info('Finished sending emails to copilots'); + return opportunity; }) .catch((err) => { From d5a80515ce7821f433366447cd8c6141804bc45a Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Tue, 7 Oct 2025 16:15:27 +0530 Subject: [PATCH 2/7] deploy branch --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e2ac728e0..5465d0c28 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -149,7 +149,7 @@ workflows: context : org-global filters: branches: - only: ['develop', 'migration-setup', 'PM-1612', 'fix-project-exposing'] + only: ['develop', 'migration-setup', 'PM-1612', 'PM-2321'] - deployProd: context : org-global filters: From 63e8aa6c1c4f6bacccb78265df0ff6f1375ecb4b Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Tue, 7 Oct 2025 16:50:53 +0530 Subject: [PATCH 3/7] remove redundant code --- src/routes/copilotRequest/approveRequest.service.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/routes/copilotRequest/approveRequest.service.js b/src/routes/copilotRequest/approveRequest.service.js index 363820dc1..33e613ba3 100644 --- a/src/routes/copilotRequest/approveRequest.service.js +++ b/src/routes/copilotRequest/approveRequest.service.js @@ -96,9 +96,6 @@ module.exports = (req, data, existingTransaction) => { await Promise.all(notificationPromises); - // send email to notify via slack - sendNotification('Copilots', config.copilotsSlackEmail); - req.log.info('Finished sending emails to copilots'); return opportunity; From dbdc3ce01523b0429642f3872b2a86498bf9d760 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Tue, 7 Oct 2025 17:22:56 +0530 Subject: [PATCH 4/7] increase timeout test --- src/util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util.js b/src/util.js index 60c71d57e..34f961dd2 100644 --- a/src/util.js +++ b/src/util.js @@ -820,10 +820,10 @@ const projectServiceUtils = { const token = yield this.getM2MToken(); const httpClient = this.getHttpClient({ id: requestId, log: logger }); httpClient.defaults.timeout = 6000; - logger.debug(`${config.identityServiceEndpoint}roles/${roleId}`, "fetching role info"); + logger.debug(`${config.identityServiceEndpoint}roles/${roleId}`, 'fetching role info'); return httpClient.get(`${config.identityServiceEndpoint}roles/${roleId}`, { params: { - fields: `subjects`, + fields: 'subjects', }, headers: { 'Content-Type': 'application/json', @@ -834,7 +834,7 @@ const projectServiceUtils = { return _.get(res, 'data.result.content', []); }); } catch (err) { - logger.debug(err, "error on getting role info"); + logger.debug(err, 'error on getting role info'); return Promise.reject(err); } }), @@ -843,7 +843,7 @@ const projectServiceUtils = { try { const token = yield this.getM2MToken(); const httpClient = this.getHttpClient({ id: requestId, log: logger }); - httpClient.defaults.timeout = 6000; + httpClient.defaults.timeout = 10000; return httpClient.get(`${config.identityServiceEndpoint}roles`, { params: { filter: `roleName=${roleName}`, From 451bec89b69f3c978ced5d8cbb1bbfb5afbce68f Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Tue, 7 Oct 2025 18:51:24 +0530 Subject: [PATCH 5/7] add logs --- src/routes/copilotRequest/approveRequest.service.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/routes/copilotRequest/approveRequest.service.js b/src/routes/copilotRequest/approveRequest.service.js index 33e613ba3..773b01caa 100644 --- a/src/routes/copilotRequest/approveRequest.service.js +++ b/src/routes/copilotRequest/approveRequest.service.js @@ -66,7 +66,11 @@ module.exports = (req, data, existingTransaction) => { .create(data, { transaction }); })) .then(async (opportunity) => { + // eslint-disable-next-line no-console + 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'); const { subjects = [] } = await util.getRoleInfo(roles[0], req.log, req.id); const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_EMAIL; const copilotPortalUrl = config.get('copilotPortalUrl'); From c7bb446dd751ec0691b4cd4d2bb35cbd4be3645d Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Tue, 7 Oct 2025 19:31:48 +0530 Subject: [PATCH 6/7] change endpoint to v6 --- config/development.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/development.json b/config/development.json index 878bc6693..5b8eb1360 100644 --- a/config/development.json +++ b/config/development.json @@ -6,7 +6,7 @@ "copilotPortalUrl": "https://copilots.topcoder-dev.com", "fileServiceEndpoint": "https://api.topcoder-dev.com/v5/files", "memberServiceEndpoint": "https://api.topcoder-dev.com/v5/members", - "identityServiceEndpoint": "https://api.topcoder-dev.com/v3/", + "identityServiceEndpoint": "https://api.topcoder-dev.com/v6/", "taasJobApiUrl": "https://api.topcoder-dev.com/v5/jobs", "sfdcBillingAccountNameField": "Billing_Account_name__c", "sfdcBillingAccountMarkupField": "Mark_Up__c", From dff7fd5de1bbc9518dd781e0aabdb5c4f1d14f55 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Tue, 7 Oct 2025 20:20:35 +0530 Subject: [PATCH 7/7] revert timeout --- src/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.js b/src/util.js index 34f961dd2..da98ce7d4 100644 --- a/src/util.js +++ b/src/util.js @@ -843,7 +843,7 @@ const projectServiceUtils = { try { const token = yield this.getM2MToken(); const httpClient = this.getHttpClient({ id: requestId, log: logger }); - httpClient.defaults.timeout = 10000; + httpClient.defaults.timeout = 6000; return httpClient.get(`${config.identityServiceEndpoint}roles`, { params: { filter: `roleName=${roleName}`,