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

Commit 81f76d4

Browse files
committed
Merge branch 'develop'
2 parents 398c71e + 6bc5d34 commit 81f76d4

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = {
3232
// Topcoder APIs
3333
V5_CHALLENGE_API_URL: process.env.V5_CHALLENGE_API_URL || 'http://localhost:4000/v5/challenges',
3434
V5_CHALLENGE_TYPE_API_URL: process.env.V5_CHALLENGE_TYPE_API_URL || 'http://localhost:4000/v5/challenge-types',
35+
V4_CHALLENGE_TYPE_API_URL: process.env.V4_CHALLENGE_TYPE_API_URL || 'http://localhost:4000/v4/challenge-types',
3536
V4_CHALLENGE_API_URL: process.env.V4_CHALLENGE_API_URL || 'http://localhost:4000/v4/challenges',
3637
V4_TECHNOLOGIES_API_URL: process.env.V4_TECHNOLOGIES_API_URL || 'http://localhost:4000/v4/technologies',
3738
V4_PLATFORMS_API_URL: process.env.V4_PLATFORMS_API_URL || 'http://localhost:4000/v4/platforms',

src/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const challengeStatuses = {
4747

4848
const challengeAbbreviations = {
4949
TASK: 'TASK',
50-
FIRST_2_FINISH: 'FIRST_2_FINISH'
50+
FIRST_2_FINISH: 'FIRST_2_FINISH',
51+
DESIGN_FIRST_2_FINISH: 'DESIGN_FIRST_2_FINISH'
5152
}
5253

5354
module.exports = {

src/services/ProcessorService.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,28 @@ async function parsePayload (payload, m2mToken, isCreated = true) {
9595
data.milestoneId = 1
9696
}
9797
if (payload.typeId) {
98-
const typeRes = await helper.getRequest(`${config.V5_CHALLENGE_TYPE_API_URL}/${payload.typeId}`, m2mToken)
99-
data.subTrack = typeRes.body.abbreviation // FIXME: thomas
98+
const v5Type = await helper.getRequest(`${config.V5_CHALLENGE_TYPE_API_URL}/${payload.typeId}`, m2mToken)
99+
const v4TypeList = await helper.getRequest(`${config.V4_CHALLENGE_TYPE_API_URL}`, m2mToken)
100+
const v4Type = _.find(_.get(v4TypeList, 'body.result.content', []), type => type.id === v5Type.body.legacyId)
101+
if (!v4Type) {
102+
throw new Error(`There is no mapping between v5 Type ${v5Type.body.name} and V4`)
103+
}
104+
data.subTrack = v4Type.subTrack
100105
// TASK is named as FIRST_2_FINISH on legacy
101-
if (data.subTrack === constants.challengeAbbreviations.TASK) {
106+
if (v5Type.body.abbreviation === constants.challengeAbbreviations.TASK) {
102107
data.task = true
103-
data.subTrack = constants.challengeAbbreviations.FIRST_2_FINISH
108+
switch (_.toLower(_.toString(data.track))) {
109+
case 'develop':
110+
data.subTrack = constants.challengeAbbreviations.FIRST_2_FINISH
111+
break
112+
case 'design':
113+
data.subTrack = constants.challengeAbbreviations.DESIGN_FIRST_2_FINISH
114+
break
115+
default:
116+
throw new Error(`Cannot create a task for track ${data.track}`)
117+
}
104118
}
105-
data.legacyTypeId = typeRes.body.legacyId
119+
data.legacyTypeId = v5Type.body.legacyId
106120
}
107121
if (payload.description) {
108122
try {

0 commit comments

Comments
 (0)