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

Commit bed3ec7

Browse files
committed
Trying to force the v4 es feeder on create/update
1 parent 2a7e938 commit bed3ec7

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = {
5656
V4_PLATFORMS_API_URL: process.env.V4_PLATFORMS_API_URL || 'http://localhost:4000/v4/platforms',
5757
V5_PROJECTS_API_URL: process.env.V5_PROJECTS_API_URL || 'https://api.topcoder-dev.com/v5/projects',
5858
V5_CHALLENGE_MIGRATION_API_URL: process.env.V5_CHALLENGE_MIGRATION_API_URL || 'https://api.topcoder-dev.com/v5/challenge-migration',
59+
V4_ES_FEEDER_API_URL: process.env.V4_ES_FEEDER_API_URL || 'https://api.topcoder-dev.com/v4/esfeeder/challenges',
5960

6061
V5_GROUPS_API_URL: process.env.V5_GROUPS_API_URL || 'https://api.topcoder-dev.com/v5/groups',
6162

src/common/helper.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ async function postBusEvent (topic, payload) {
150150
})
151151
}
152152

153+
async function forceV4ESFeeder (legacyId) {
154+
const token = await getM2MToken()
155+
const body = {
156+
param: {
157+
challengeIds: [legacyId]
158+
}
159+
}
160+
await request.put(`${config.V4_ES_FEEDER_API_URL}`).send(body).set({ Authorization: `Bearer ${token}` })
161+
}
162+
153163
module.exports = {
154164
getInformixConnection,
155165
getKafkaOptions,
@@ -158,5 +168,6 @@ module.exports = {
158168
getRequest,
159169
putRequest,
160170
postRequest,
161-
postBusEvent
171+
postBusEvent,
172+
forceV4ESFeeder
162173
}

src/services/ProcessorService.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ async function processCreate (message) {
291291
logger.debug('processCreate :: beforeTry')
292292
try {
293293
const newChallenge = await helper.postRequest(`${config.V4_CHALLENGE_API_URL}`, { param: _.omit(saveDraftContestDTO, ['groupsToBeAdded', 'groupsToBeDeleted']) }, m2mToken)
294+
await helper.forceV4ESFeeder(newChallenge.body.result.content.id)
294295
await associateChallengeGroups(saveDraftContestDTO.groupsToBeAdded, saveDraftContestDTO.groupsToBeDeleted, newChallenge.body.result.content.id)
295296
await helper.patchRequest(`${config.V5_CHALLENGE_API_URL}/${challengeUuid}`, {
296297
legacy: {
@@ -435,16 +436,7 @@ async function processUpdate (message) {
435436
}
436437
}
437438
}
438-
// we can't switch the challenge type
439-
// TODO: track is missing from the response.
440-
// if (message.payload.legacy.track) {
441-
// const newTrack = message.payload.legacy.track
442-
// // track information is stored in subTrack of V4 API
443-
// if (challenge.track !== newTrack) {
444-
// // refer ContestDirectManager.prepare in ap-challenge-microservice
445-
// throw new Error('You can\'t change challenge track')
446-
// }
447-
// }
439+
await helper.forceV4ESFeeder(message.payload.legacyId)
448440
} catch (e) {
449441
logger.error('processUpdate Catch', e)
450442
throw e

0 commit comments

Comments
 (0)