From e056f933d4f0d792a2619b93d746b8fcced939d5 Mon Sep 17 00:00:00 2001 From: Dhruvit Raithatha Date: Fri, 8 Dec 2023 09:00:34 +0530 Subject: [PATCH] fix: don't apply tags when creating/updating challenges --- services/ChallengeService.js | 6 ++++-- services/CopilotPaymentService.js | 1 - services/IssueService.js | 1 - utils/topcoder-api-helper.js | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/services/ChallengeService.js b/services/ChallengeService.js index 93fca2e..649f0c8 100644 --- a/services/ChallengeService.js +++ b/services/ChallengeService.js @@ -20,13 +20,15 @@ const dbHelper = require('../utils/db-helper'); * @param {Object} event the event */ async function handleChallengeTagsUpdate(event) { - const tags = event.data.tags.map((tag) => tag.name); + const tags = event.data.tags; await Promise.all( event.data.challengeUUIDsList.map(async (challengeUUIDs) => { if (_.isString(challengeUUIDs)) { // repoUrl challengeUUIDs = await dbHelper.queryChallengeUUIDsByRepoUrl(challengeUUIDs); } - return challengeUUIDs.map(async (challengeUUID) => await topcoderApiHelper.updateChallenge(challengeUUID, {tags})); + return challengeUUIDs.map( + async (challengeUUID) => await topcoderApiHelper.applySkillsSetToChallenge(challengeUUID, tags) + ); }).reduce((a, b) => _.concat(a, b), []) ).then((resps) => { logger.debug(`handleChallengeTagsUpdate updated ${_.size(resps)} challenges successfully.`); diff --git a/services/CopilotPaymentService.js b/services/CopilotPaymentService.js index 944d50e..df152a6 100644 --- a/services/CopilotPaymentService.js +++ b/services/CopilotPaymentService.js @@ -194,7 +194,6 @@ async function handlePaymentAdd(event, payment) { const newChallenge = { name: challengeTitle, projectId: project.tcDirectId, - tags: project.tags ? project.tags.map((tag) => tag.name) : [], detailedRequirements: challengeRequirements, prizes: [payment.amount], reviewType: 'INTERNAL' diff --git a/services/IssueService.js b/services/IssueService.js index 4986cc6..f7070a6 100755 --- a/services/IssueService.js +++ b/services/IssueService.js @@ -635,7 +635,6 @@ async function handleIssueCreate(event, issue, forceAssign = false) { issue.challengeUUID = await topcoderApiHelper.createChallenge({ name: issue.title, projectId, - tags: project.tags ? project.tags.map((tag) => tag.name) : [], detailedRequirements: issue.body, prizes: issue.prizes }); diff --git a/utils/topcoder-api-helper.js b/utils/topcoder-api-helper.js index 5d1484e..408d562 100644 --- a/utils/topcoder-api-helper.js +++ b/utils/topcoder-api-helper.js @@ -76,7 +76,7 @@ async function createChallenge(challenge) { }], timelineTemplateId: config.DEFAULT_TIMELINE_TEMPLATE_ID, projectId: challenge.projectId, - tags: challenge.tags, + tags: [], trackId: config.DEFAULT_TRACK_ID, legacy: { pureV5Task: true @@ -189,6 +189,7 @@ async function applySkillsSetToChallenge(challengeId, tags) { logger.debug(`Skills set applied successfully to the challenge ${challengeId}`); return response.data; } catch (err) { + // eslint-disable-next-line max-len loggerFile.info(`EndPoint: POST /standardized-skills/challenge-skills/${challengeId}, POST parameters: ${circularJSON.stringify(payload)}, Status Code:null, Error: 'Failed to apply skills set to the challenge.', Details: ${circularJSON.stringify(err)}`); logger.error(`Response Data: ${JSON.stringify(err.response.data)}`);