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

Commit 5684c6b

Browse files
Merge pull request #68 from topcoder-platform/develop
Self-service prod release
2 parents de3ae77 + 563c520 commit 5684c6b

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Example:
8080
`MIGRATION=001-migrate-taskData nf run npm run migrate`
8181

8282
## Production deployment
83+
8384
- TBD
8485

8586
## Running tests

src/controllers/syncController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function queueChallenges (filter) {
9696
// console.log('union length', combinedArray.length)
9797

9898
logger.debug(`Sync :: Total to Sync ${totalChallengesCount}`)
99-
logger.debug(`Combined Array ${JSON.stringify(combinedArray)}`)
99+
// logger.debug(`Combined Array ${JSON.stringify(combinedArray)}`)
100100

101101
while (running) {
102102
if ((page * perPage) > combinedArray.length) {

src/services/challengeService.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ async function updateChallenge (challenge) {
9393
}
9494
}
9595
})
96+
await triggerNotification(challenge.id)
9697
return challenge.id
9798
} catch (e) {
9899
throw Error(`updateChallenge Failed ${e}`)
@@ -715,7 +716,7 @@ async function buildV5Challenge (legacyId, challengeListing, challengeDetails) {
715716
} else {
716717
newPhase.isOpen = false
717718
}
718-
logger.debug(`Challenge ${legacyId} Phase ${phase.type} Status ${phase.status} - id ${newPhase.phaseId} Duration ${v5duration} = ${(v5duration / 60 / 60)} hrs or ${(v5duration / 60 / 60 / 24)} days`)
719+
// logger.debug(`Challenge ${legacyId} Phase ${phase.type} Status ${phase.status} - id ${newPhase.phaseId} Duration ${v5duration} = ${(v5duration / 60 / 60)} hrs or ${(v5duration / 60 / 60 / 24)} days`)
719720
return newPhase
720721
})
721722
newChallenge.endDate = challengeEndDate
@@ -725,8 +726,8 @@ async function buildV5Challenge (legacyId, challengeListing, challengeDetails) {
725726
const registrationPhase = _.find(phases, p => p.name === 'Registration')
726727
const submissionPhase = _.find(phases, p => p.name === 'Submission')
727728

728-
logger.debug(`Registration Phase ${JSON.stringify(registrationPhase)}`)
729-
logger.debug(`Submission Phase ${JSON.stringify(submissionPhase)}`)
729+
// logger.debug(`Registration Phase ${JSON.stringify(registrationPhase)}`)
730+
// logger.debug(`Submission Phase ${JSON.stringify(submissionPhase)}`)
730731

731732
newChallenge.currentPhaseNames = _.map(_.filter(phases, p => p.isOpen === true), 'name')
732733
if (registrationPhase) {
@@ -776,8 +777,8 @@ async function buildV5Challenge (legacyId, challengeListing, challengeDetails) {
776777
// }
777778

778779
const legacyEffortHoursData = await challengeInformixService.getEffortHoursFromIfx(legacyId)
779-
logger.debug(`Legacy Effort Hours ${JSON.stringify(legacyEffortHoursData)}`)
780-
logger.debug(`Metadata: ${JSON.stringify(metadata)}`)
780+
// logger.debug(`Legacy Effort Hours ${JSON.stringify(legacyEffortHoursData)}`)
781+
// logger.debug(`Metadata: ${JSON.stringify(metadata)}`)
781782
if (legacyEffortHoursData.length > 0) {
782783
_.forEach(effortHoursMapping, (mappingValue, key) => {
783784
logger.debug(`${JSON.stringify(mappingValue)} -> ${key}`)
@@ -789,14 +790,14 @@ async function buildV5Challenge (legacyId, challengeListing, challengeDetails) {
789790
name: key,
790791
value: legacyEffortHoursData[legacyIndex].value
791792
}
792-
logger.debug(`Not found in v5, adding ${JSON.stringify(newData)}`)
793+
// logger.debug(`Not found in v5, adding ${JSON.stringify(newData)}`)
793794
metadata.push(newData)
794795
} else {
795796
metadata[v5Index].value = legacyEffortHoursData[legacyIndex].value
796-
logger.debug(`Metadata found in v5, updating v5 index: ${v5Index} ${legacyIndex} V5 Metadata ${JSON.stringify(metadata[v5Index])}`)
797+
// logger.debug(`Metadata found in v5, updating v5 index: ${v5Index} ${legacyIndex} V5 Metadata ${JSON.stringify(metadata[v5Index])}`)
797798
}
798799
} else {
799-
logger.debug(`Key ${key} not found in legacy array`)
800+
// logger.debug(`Key ${key} not found in legacy array`)
800801
}
801802
})
802803
}
@@ -883,10 +884,24 @@ async function convertGroupIdsToV5UUIDs (oldIds) {
883884
return groups
884885
}
885886

887+
async function triggerNotification (v5Id) {
888+
const token = await getM2MToken()
889+
const url = `${config.CHALLENGE_API_URL}/${v5Id}/notifications`
890+
// logger.debug(`Get Challenge from V5 URL ${url}`)
891+
let res = null
892+
try {
893+
res = await axios.post(url, {}, { headers: { Authorization: `Bearer ${token}` } })
894+
} catch (e) {
895+
logger.error(`Axios Error: ${JSON.stringify(e)}`)
896+
}
897+
// console.log(res.data)
898+
return res.data || null
899+
}
900+
886901
async function getChallengeFromV5API (legacyId) {
887902
const token = await getM2MToken()
888903
const url = `${config.CHALLENGE_API_URL}?legacyId=${legacyId}&perPage=1&page=1`
889-
logger.debug(`Get Challenge from V5 URL ${url}`)
904+
// logger.debug(`Get Challenge from V5 URL ${url}`)
890905
let res = null
891906
try {
892907
res = await axios.get(url, { headers: { Authorization: `Bearer ${token}` } })

src/services/resourceService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async function createResourceInV5 (challengeId, memberHandle, roleId) {
240240
}
241241
let res = null
242242
try {
243-
logger.debug(`Creating Resource ${challengeId}, ${memberHandle}, ${roleId}`)
243+
// logger.debug(`Creating Resource ${challengeId}, ${memberHandle}, ${roleId}`)
244244
res = await axios.post(url, data, { headers: { Authorization: `Bearer ${token}` } })
245245
} catch (e) {
246246
logger.error(`get from v5 error ${JSON.stringify(e)}`)

0 commit comments

Comments
 (0)