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

Support tasks #20

Merged
merged 2 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The following parameters can be set in config files or in env variables:
- V4_CHALLENGE_API_URL: v4 challenge api url, default value is 'http://localhost:4000/v4/challenges'
- V4_TECHNOLOGIES_API_URL: v4 technologies api url, default value is 'http://localhost:4000/v4/technologies'
- V4_PLATFORMS_API_URL: v4 platforms api url, default value is 'http://localhost:4000/v4/platforms'
- TASK_TYPE_ID: The v5 Type ID for tasks
- TASK_TYPE_IDS: The v5 Type ID for tasks per track
- CHALLENGE_TYPE_ID: The v5 Type ID for regular challenges
- FIRST_2_FINISH_TYPE_ID: The v5 Type ID for F2F challenges

Expand Down
6 changes: 6 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ module.exports = {

// challenge types
TASK_TYPE_ID: process.env.TASK_TYPE_ID || 'e885273d-aeda-42c0-917d-bfbf979afbba',
TASK_TYPE_IDS: {
DEVELOP: process.env.DEVELOP_TASK_TYPE_ID || 'e885273d-aeda-42c0-917d-bfbf979afbba',
DESIGN: process.env.DESIGN_TASK_TYPE_ID || '149a2013-92b9-4ca9-b35d-c337d47a2490',
QA: process.env.QA_TASK_TYPE_ID || 'a91e69fd-6240-4227-8484-66b8defc4ca9',
DATA_SCENCE: process.env.DATA_SCENCE_TASK_TYPE_ID || 'b3b60e22-e302-4db8-bef8-4eaff965565f'
},
CHALLENGE_TYPE_ID: process.env.CHALLENGE_TYPE_ID || '94eee466-9255-4b60-88d8-4f59c1810dd0',
FIRST_2_FINISH_TYPE_ID: process.env.FIRST_2_FINISH_TYPE_ID || '6950164f-3c5e-4bdc-abc8-22aaf5a1bd49'
}
10 changes: 8 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ const challengeAbbreviations = {

const legacySubTrackMapping = {
[_.toLower(challengeTracks.DEVELOP)]: {
[config.TASK_TYPE_ID]: challengeAbbreviations.FIRST_2_FINISH,
[config.TASK_TYPE_IDS.DEVELOP]: challengeAbbreviations.FIRST_2_FINISH,
[config.CHALLENGE_TYPE_ID]: challengeAbbreviations.CODE,
[config.FIRST_2_FINISH_TYPE_ID]: challengeAbbreviations.FIRST_2_FINISH
},
[_.toLower(challengeTracks.DESIGN)]: {
[config.TASK_TYPE_ID]: challengeAbbreviations.DESIGN_FIRST_2_FINISH,
[config.TASK_TYPE_IDS.DESIGN]: challengeAbbreviations.DESIGN_FIRST_2_FINISH,
[config.CHALLENGE_TYPE_ID]: challengeAbbreviations.APPLICATION_FRONT_END_DESIGN,
[config.FIRST_2_FINISH_TYPE_ID]: challengeAbbreviations.DESIGN_FIRST_2_FINISH
},
[_.toLower(challengeTracks.QA)]: {
[config.TASK_TYPE_IDS.QA]: challengeAbbreviations.FIRST_2_FINISH
},
[_.toLower(challengeTracks.DATA_SCIENCE)]: {
[config.TASK_TYPE_IDS.DATA_SCIENCE]: challengeAbbreviations.FIRST_2_FINISH
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/services/ProcessorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ async function getLegacyTrackInformation (legacyTrack, typeId, m2mToken) {
}

// If it's a private task, set the `task` property to `true`
if (typeId === config.TASK_TYPE_ID) {
// Tasks can only be created for the develop and design tracks
if (data.track !== constants.challengeTracks.DEVELOP && data.track !== constants.challengeTracks.DESIGN) {
throw new Error(`Cannot create a task for track ${data.track}`)
if (_.values(config.TASK_TYPE_IDS).includes(typeId)) {
// Tasks can only be created for the develop and design tracks so we're setting the track for QA/DS to DEVELOP
if (data.track === constants.challengeTracks.QA || data.track !== constants.challengeTracks.DATA_SCIENCE) {
data.track = constants.challengeTracks.DEVELOP
}
data.task = true
}
Expand Down Expand Up @@ -283,7 +283,7 @@ processCreate.schema = {
confidentialityType: Joi.string(),
directProjectId: Joi.number(),
forumId: Joi.number().integer().positive()
}),
}).unknown(true),
billingAccountId: Joi.number(),
name: Joi.string().required(),
description: Joi.string(),
Expand Down Expand Up @@ -353,7 +353,7 @@ async function processUpdate (message) {
if (message.payload.status === constants.challengeStatuses.Completed && challenge.currentStatus !== constants.challengeStatuses.Completed) {
const challengeUuid = message.payload.id
const v5Challenge = await helper.getRequest(`${config.V5_CHALLENGE_API_URL}/${challengeUuid}`, m2mToken)
if (v5Challenge.body.typeId === config.TASK_TYPE_ID) {
if (_.values(config.TASK_TYPE_IDS).includes(v5Challenge.body.typeId)) {
logger.info('Challenge type is TASK')
if (!message.payload.winners || message.payload.winners.length === 0) {
throw new Error('Cannot close challenge without winners')
Expand Down Expand Up @@ -397,7 +397,7 @@ processUpdate.schema = {
directProjectId: Joi.number(),
forumId: Joi.number().integer().positive(),
informixModified: Joi.string()
}),
}).unknown(true),
billingAccountId: Joi.number(),
typeId: Joi.string(),
name: Joi.string(),
Expand Down