Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 94ac037

Browse files
committed
Change when we set the copilot - now at issue create stage, not issue close stage
1 parent 44c876e commit 94ac037

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

services/IssueService.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,13 @@ async function handleIssueClose(event, issue) { // eslint-disable-line
485485
};
486486
await topcoderApiHelper.updateChallenge(dbIssue.challengeUUID, updateBody);
487487

488-
const copilotAlreadySet = await topcoderApiHelper.roleAlreadySet(dbIssue.challengeUUID, config.ROLE_ID_COPILOT);
489488
const createCopilotPayments = project.createCopilotPayments === 'true' &&
490-
event.copilot.topcoderUsername.toLowerCase() !== assigneeMember.topcoderUsername.toLowerCase();
489+
event.copilot.topcoderUsername.toLowerCase() !== assigneeMember.topcoderUsername.toLowerCase();
491490
event.createCopilotPayments = createCopilotPayments;
492491

493-
if (!copilotAlreadySet && createCopilotPayments) {
494-
logger.debugWithContext(`Getting the topcoder member ID for copilot name : ${event.copilot.topcoderUsername}`, event, issue);
495-
// get copilot tc user id
496-
await topcoderApiHelper.addResourceToChallenge(dbIssue.challengeUUID, event.copilot.topcoderUsername, config.ROLE_ID_COPILOT);
492+
if (createCopilotPayments) {
493+
logger.debugWithContext(`Setting copilot payment`);
494+
497495
const updateBody = {
498496
prizeSets: [{
499497
type: 'placement',
@@ -507,13 +505,9 @@ async function handleIssueClose(event, issue) { // eslint-disable-line
507505
};
508506
await topcoderApiHelper.updateChallenge(dbIssue.challengeUUID, updateBody);
509507

510-
} else {
511-
if(copilotAlreadySet){
512-
logger.debugWithContext('Copilot is already set, so skipping', event, issue);
513-
}
514-
if(!createCopilotPayments){
508+
}
509+
else {
515510
logger.debugWithContext('Create copilot payments is unchecked on the Topcoder-X project setup, so skipping', event, issue);
516-
}
517511
}
518512

519513
logger.debugWithContext(`Getting the topcoder member ID for member name: ${assigneeMember.topcoderUsername}`, event, issue);
@@ -643,6 +637,11 @@ async function handleIssueCreate(event, issue, forceAssign = false) {
643637
status: constants.ISSUE_STATUS.CHALLENGE_CREATION_SUCCESSFUL,
644638
updatedAt: new Date()
645639
});
640+
641+
logger.debugWithContext(`Adding copilot to issue: ${event.copilot.topcoderUsername}`, event, issue);
642+
// get copilot tc user id
643+
await topcoderApiHelper.addResourceToChallenge(issue.challengeUUID, event.copilot.topcoderUsername, config.ROLE_ID_COPILOT);
644+
646645
} catch (e) {
647646
logger.error(`Challenge creation failure: ${e}`);
648647
delete issueCreationLock[creationLockKey];

0 commit comments

Comments
 (0)