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

Commit 8a830ce

Browse files
authored
Merge pull request #20 from topcoder-platform/support-tasks
Support tasks
2 parents 53ac68e + d910db4 commit 8a830ce

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The following parameters can be set in config files or in env variables:
4949
- V4_CHALLENGE_API_URL: v4 challenge api url, default value is 'http://localhost:4000/v4/challenges'
5050
- V4_TECHNOLOGIES_API_URL: v4 technologies api url, default value is 'http://localhost:4000/v4/technologies'
5151
- V4_PLATFORMS_API_URL: v4 platforms api url, default value is 'http://localhost:4000/v4/platforms'
52-
- TASK_TYPE_ID: The v5 Type ID for tasks
52+
- TASK_TYPE_IDS: The v5 Type ID for tasks per track
5353
- CHALLENGE_TYPE_ID: The v5 Type ID for regular challenges
5454
- FIRST_2_FINISH_TYPE_ID: The v5 Type ID for F2F challenges
5555

config/default.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ module.exports = {
4545

4646
// challenge types
4747
TASK_TYPE_ID: process.env.TASK_TYPE_ID || 'e885273d-aeda-42c0-917d-bfbf979afbba',
48+
TASK_TYPE_IDS: {
49+
DEVELOP: process.env.DEVELOP_TASK_TYPE_ID || 'e885273d-aeda-42c0-917d-bfbf979afbba',
50+
DESIGN: process.env.DESIGN_TASK_TYPE_ID || '149a2013-92b9-4ca9-b35d-c337d47a2490',
51+
QA: process.env.QA_TASK_TYPE_ID || 'a91e69fd-6240-4227-8484-66b8defc4ca9',
52+
DATA_SCENCE: process.env.DATA_SCENCE_TASK_TYPE_ID || 'b3b60e22-e302-4db8-bef8-4eaff965565f'
53+
},
4854
CHALLENGE_TYPE_ID: process.env.CHALLENGE_TYPE_ID || '94eee466-9255-4b60-88d8-4f59c1810dd0',
4955
FIRST_2_FINISH_TYPE_ID: process.env.FIRST_2_FINISH_TYPE_ID || '6950164f-3c5e-4bdc-abc8-22aaf5a1bd49'
5056
}

src/constants.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,20 @@ const challengeAbbreviations = {
6565

6666
const legacySubTrackMapping = {
6767
[_.toLower(challengeTracks.DEVELOP)]: {
68-
[config.TASK_TYPE_ID]: challengeAbbreviations.FIRST_2_FINISH,
68+
[config.TASK_TYPE_IDS.DEVELOP]: challengeAbbreviations.FIRST_2_FINISH,
6969
[config.CHALLENGE_TYPE_ID]: challengeAbbreviations.CODE,
7070
[config.FIRST_2_FINISH_TYPE_ID]: challengeAbbreviations.FIRST_2_FINISH
7171
},
7272
[_.toLower(challengeTracks.DESIGN)]: {
73-
[config.TASK_TYPE_ID]: challengeAbbreviations.DESIGN_FIRST_2_FINISH,
73+
[config.TASK_TYPE_IDS.DESIGN]: challengeAbbreviations.DESIGN_FIRST_2_FINISH,
7474
[config.CHALLENGE_TYPE_ID]: challengeAbbreviations.APPLICATION_FRONT_END_DESIGN,
7575
[config.FIRST_2_FINISH_TYPE_ID]: challengeAbbreviations.DESIGN_FIRST_2_FINISH
76+
},
77+
[_.toLower(challengeTracks.QA)]: {
78+
[config.TASK_TYPE_IDS.QA]: challengeAbbreviations.FIRST_2_FINISH
79+
},
80+
[_.toLower(challengeTracks.DATA_SCIENCE)]: {
81+
[config.TASK_TYPE_IDS.DATA_SCIENCE]: challengeAbbreviations.FIRST_2_FINISH
7682
}
7783
}
7884

src/services/ProcessorService.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ async function getLegacyTrackInformation (legacyTrack, typeId, m2mToken) {
8888
}
8989

9090
// If it's a private task, set the `task` property to `true`
91-
if (typeId === config.TASK_TYPE_ID) {
92-
// Tasks can only be created for the develop and design tracks
93-
if (data.track !== constants.challengeTracks.DEVELOP && data.track !== constants.challengeTracks.DESIGN) {
94-
throw new Error(`Cannot create a task for track ${data.track}`)
91+
if (_.values(config.TASK_TYPE_IDS).includes(typeId)) {
92+
// Tasks can only be created for the develop and design tracks so we're setting the track for QA/DS to DEVELOP
93+
if (data.track === constants.challengeTracks.QA || data.track !== constants.challengeTracks.DATA_SCIENCE) {
94+
data.track = constants.challengeTracks.DEVELOP
9595
}
9696
data.task = true
9797
}
@@ -284,7 +284,7 @@ processCreate.schema = {
284284
confidentialityType: Joi.string(),
285285
directProjectId: Joi.number(),
286286
forumId: Joi.number().integer().positive()
287-
}),
287+
}).unknown(true),
288288
billingAccountId: Joi.number(),
289289
name: Joi.string().required(),
290290
description: Joi.string(),
@@ -355,7 +355,7 @@ async function processUpdate (message) {
355355
if (message.payload.status === constants.challengeStatuses.Completed && challenge.currentStatus !== constants.challengeStatuses.Completed) {
356356
const challengeUuid = message.payload.id
357357
const v5Challenge = await helper.getRequest(`${config.V5_CHALLENGE_API_URL}/${challengeUuid}`, m2mToken)
358-
if (v5Challenge.body.typeId === config.TASK_TYPE_ID) {
358+
if (_.values(config.TASK_TYPE_IDS).includes(v5Challenge.body.typeId)) {
359359
logger.info('Challenge type is TASK')
360360
if (!message.payload.winners || message.payload.winners.length === 0) {
361361
throw new Error('Cannot close challenge without winners')
@@ -399,7 +399,7 @@ processUpdate.schema = {
399399
directProjectId: Joi.number(),
400400
forumId: Joi.number().integer().positive(),
401401
informixModified: Joi.string()
402-
}),
402+
}).unknown(true),
403403
billingAccountId: Joi.number(),
404404
typeId: Joi.string(),
405405
name: Joi.string(),

0 commit comments

Comments
 (0)