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

Sync master with develop #35

Merged
merged 9 commits into from
Oct 23, 2020
Prev Previous commit
Next Next commit
Update to use v5 challenge api
  • Loading branch information
callmekatootie committed Oct 23, 2020
commit 2cf6a9fb38552274a40063da5c50ea38e7949760
2 changes: 1 addition & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
: '["https://topcoder-dev.auth0.com/", "https://api.topcoder.com"]',

MONGODB_URL: process.env.MONGODB_URL || 'mongodb://localhost:27017/leaderboardDB',
CHALLENGE_API_URL: process.env.CHALLENGE_API_URL || 'https://api.topcoder-dev.com/v4/challenges',
CHALLENGE_API_URL: process.env.CHALLENGE_API_URL || 'https://api.topcoder-dev.com/v5/challenges',
MEMBER_API_URL: process.env.MEMBER_API_URL || 'https://api.topcoder-dev.com/v3/users',

GROUP_IDS: process.env.GROUP_IDS || '202343,20000000', // Comma separated string of Group IDs,
Expand Down
2 changes: 1 addition & 1 deletion src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const m2m = m2mAuth(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_
const isGroupIdValid = (groupIds) => {
// Get the Group IDs from config
const confGroupIds = config.GROUP_IDS.split(',')
if (_.intersectionBy(confGroupIds, groupIds, parseInt).length !== 0) {
if (_.intersectionBy(confGroupIds, groupIds).length !== 0) {
return true
}
return false
Expand Down
6 changes: 3 additions & 3 deletions src/services/LeaderboardService.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ async function createLeaderboard (challengeId, memberId, review) {
const { testsPassed, totalTestCases } = calculateResult(review)

const challengeDetailRes = await helper.reqToAPI(
`${config.CHALLENGE_API_URL}?filter=id=${challengeId}`)
const challenge = _.get(challengeDetailRes, 'body.result.content[0]')
`${config.CHALLENGE_API_URL}?legacyId=${challengeId}`)
const challenge = _.get(challengeDetailRes, 'body[0]')
if (!challenge) {
throw new errors.BadRequestError(`Challenge # ${challengeId} doesn't exist`)
}

const groupIds = challenge.groupIds
const groupIds = challenge.groups
if (!helper.isGroupIdValid(groupIds)) {
logger.debug(`Group ID (${JSON.stringify(groupIds)}) of Challenge # ${challengeId} is not in the configured set of Ids (${config.GROUP_IDS}) configured for processing!`)
// Ignore the message
Expand Down