Skip to content

Commit f7579a0

Browse files
committed
fix: cancel all copilot requests for a project when manually copilot is added
1 parent aa5cc62 commit f7579a0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/routes/projectMemberInvites/update.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ module.exports = [
173173
transaction: t,
174174
});
175175
} else if (source === INVITE_SOURCE.WORK_MANAGER) {
176+
req.log.info("cancelling all existing requests", source);
176177
const allCopilotRequestsByProjectId = await models.CopilotRequest.findAll({
177178
where: {
178179
projectId: invite.projectId,
@@ -181,6 +182,7 @@ module.exports = [
181182
});
182183

183184
const requestIds = allCopilotRequestsByProjectId.map(item => item.id);
185+
req.log.info("requestIds", requestIds);
184186

185187
await models.CopilotRequest.update({
186188
status: COPILOT_REQUEST_STATUS.CANCELED,
@@ -193,6 +195,8 @@ module.exports = [
193195
transaction: t,
194196
});
195197

198+
req.log.info("updated copilot request");
199+
196200
const allCopilotOpportunityByRequestIds = await models.CopilotOpportunity.findAll({
197201
where: {
198202
copilotRequestId: {
@@ -202,6 +206,8 @@ module.exports = [
202206
transaction: t,
203207
});
204208

209+
req.log.info("allCopilotOpportunityByRequestIds", allCopilotOpportunityByRequestIds.length);
210+
205211
await models.CopilotOpportunity.update({
206212
status: COPILOT_OPPORTUNITY_STATUS.CANCELED,
207213
}, {
@@ -213,6 +219,8 @@ module.exports = [
213219
transaction: t,
214220
});
215221

222+
req.log.info("updated copilot opportunity");
223+
216224
await models.CopilotApplication.update({
217225
status: COPILOT_APPLICATION_STATUS.CANCELED,
218226
}, {
@@ -223,6 +231,8 @@ module.exports = [
223231
},
224232
transaction: t,
225233
});
234+
235+
req.log.info("updated CopilotApplication");
226236
}
227237

228238
await t.commit();

0 commit comments

Comments
 (0)