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

Commit 146c502

Browse files
Repost all resources on kafka so they will get created on legacy
1 parent b4a6530 commit 146c502

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

ReadMe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ The following parameters can be set in config files or in env variables:
3939
- RETRY_TIMEOUT: The timeout to retry processing the same message
4040
- CREATE_CHALLENGE_TOPIC: the create challenge Kafka message topic, default value is 'challenge.notification.create'
4141
- UPDATE_CHALLENGE_TOPIC: the update challenge Kafka message topic, default value is 'challenge.notification.update'
42+
- RESOURCE_CREATE_TOPIC: the resource create Kafka message topic, default value is 'challenge.action.resource.create'
4243
- AUTH0_URL: Auth0 URL, used to get TC M2M token
4344
- AUTH0_AUDIENCE: Auth0 audience, used to get TC M2M token
4445
- TOKEN_CACHE_TIME: Auth0 token cache time, used to get TC M2M token
4546
- AUTH0_CLIENT_ID: Auth0 client id, used to get TC M2M token
4647
- AUTH0_CLIENT_SECRET: Auth0 client secret, used to get TC M2M token
4748
- AUTH0_PROXY_SERVER_URL: Proxy Auth0 URL, used to get TC M2M token
4849
- V5_CHALLENGE_API_URL: v5 challenge api url, default value is 'http://localhost:4000/v5/challenges'
50+
- V5_RESOURCES_API_URL: v5 resources api url, default value is 'http://localhost:4000/v5/resources'
4951
- V5_CHALLENGE_TYPE_API_URL: v5 challenge type api url, default value is 'http://localhost:4000/v5/challenge-types'
5052
- V4_CHALLENGE_API_URL: v4 challenge api url, default value is 'http://localhost:4000/v4/challenges'
5153
- V4_TECHNOLOGIES_API_URL: v4 technologies api url, default value is 'http://localhost:4000/v4/technologies'

config/default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = {
2121
// Topics to listen
2222
CREATE_CHALLENGE_TOPIC: process.env.CREATE_CHALLENGE_TOPIC || 'challenge.notification.create',
2323
UPDATE_CHALLENGE_TOPIC: process.env.UPDATE_CHALLENGE_TOPIC || 'challenge.notification.update',
24+
RESOURCE_CREATE_TOPIC: process.env.RESOURCE_CREATE_TOPIC || 'challenge.action.resource.create',
2425

2526
// Auth0 parameters
2627
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token',
@@ -47,6 +48,7 @@ module.exports = {
4748
},
4849
// Topcoder APIs
4950
V5_CHALLENGE_API_URL: process.env.V5_CHALLENGE_API_URL || 'http://localhost:4000/v5/challenges',
51+
V5_RESOURCES_API_URL: process.env.V5_RESOURCES_API_URL || 'http://localhost:4000/v5/resources',
5052
V5_CHALLENGE_TYPE_API_URL: process.env.V5_CHALLENGE_TYPE_API_URL || 'http://localhost:4000/v5/challenge-types',
5153
V4_CHALLENGE_TYPE_API_URL: process.env.V4_CHALLENGE_TYPE_API_URL || 'http://localhost:4000/v4/challenge-types',
5254
V4_CHALLENGE_API_URL: process.env.V4_CHALLENGE_API_URL || 'http://localhost:4000/v4/challenges',

src/services/ProcessorService.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ async function processCreate (message) {
303303
},
304304
legacyId: newChallenge.body.result.content.id
305305
}, m2mToken)
306+
// Repost all challenge resource on Kafka so they will get created on legacy by the legacy-challenge-resource-processor
307+
const challengeResourcesResponse = await helper.getRequest(`${config.V5_RESOURCES_API_URL}?challengeId=${challengeUuid}&perPage=100`, m2mToken)
308+
for (const resource of (challengeResourcesResponse.body || [])) {
309+
await helper.postBusEvent(config.RESOURCE_CREATE_TOPIC, _.pick(resource, ['id', 'challengeId', 'memberId', 'memberHandle', 'roleId', 'created', 'createdBy', 'updated', 'updatedBy', 'legacyId']))
310+
}
306311
logger.debug('End of processCreate')
307312
} catch (e) {
308313
logger.error('processCreate Catch', e)

0 commit comments

Comments
 (0)