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

Self-service prod release #68

Merged
merged 3 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Example:
`MIGRATION=001-migrate-taskData nf run npm run migrate`

## Production deployment

- TBD

## Running tests
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/syncController.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function queueChallenges (filter) {
// console.log('union length', combinedArray.length)

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

while (running) {
if ((page * perPage) > combinedArray.length) {
Expand Down
33 changes: 24 additions & 9 deletions src/services/challengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ async function updateChallenge (challenge) {
}
}
})
await triggerNotification(challenge.id)
return challenge.id
} catch (e) {
throw Error(`updateChallenge Failed ${e}`)
Expand Down Expand Up @@ -715,7 +716,7 @@ async function buildV5Challenge (legacyId, challengeListing, challengeDetails) {
} else {
newPhase.isOpen = false
}
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`)
// 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`)
return newPhase
})
newChallenge.endDate = challengeEndDate
Expand All @@ -725,8 +726,8 @@ async function buildV5Challenge (legacyId, challengeListing, challengeDetails) {
const registrationPhase = _.find(phases, p => p.name === 'Registration')
const submissionPhase = _.find(phases, p => p.name === 'Submission')

logger.debug(`Registration Phase ${JSON.stringify(registrationPhase)}`)
logger.debug(`Submission Phase ${JSON.stringify(submissionPhase)}`)
// logger.debug(`Registration Phase ${JSON.stringify(registrationPhase)}`)
// logger.debug(`Submission Phase ${JSON.stringify(submissionPhase)}`)

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

const legacyEffortHoursData = await challengeInformixService.getEffortHoursFromIfx(legacyId)
logger.debug(`Legacy Effort Hours ${JSON.stringify(legacyEffortHoursData)}`)
logger.debug(`Metadata: ${JSON.stringify(metadata)}`)
// logger.debug(`Legacy Effort Hours ${JSON.stringify(legacyEffortHoursData)}`)
// logger.debug(`Metadata: ${JSON.stringify(metadata)}`)
if (legacyEffortHoursData.length > 0) {
_.forEach(effortHoursMapping, (mappingValue, key) => {
logger.debug(`${JSON.stringify(mappingValue)} -> ${key}`)
Expand All @@ -789,14 +790,14 @@ async function buildV5Challenge (legacyId, challengeListing, challengeDetails) {
name: key,
value: legacyEffortHoursData[legacyIndex].value
}
logger.debug(`Not found in v5, adding ${JSON.stringify(newData)}`)
// logger.debug(`Not found in v5, adding ${JSON.stringify(newData)}`)
metadata.push(newData)
} else {
metadata[v5Index].value = legacyEffortHoursData[legacyIndex].value
logger.debug(`Metadata found in v5, updating v5 index: ${v5Index} ${legacyIndex} V5 Metadata ${JSON.stringify(metadata[v5Index])}`)
// logger.debug(`Metadata found in v5, updating v5 index: ${v5Index} ${legacyIndex} V5 Metadata ${JSON.stringify(metadata[v5Index])}`)
}
} else {
logger.debug(`Key ${key} not found in legacy array`)
// logger.debug(`Key ${key} not found in legacy array`)
}
})
}
Expand Down Expand Up @@ -883,10 +884,24 @@ async function convertGroupIdsToV5UUIDs (oldIds) {
return groups
}

async function triggerNotification (v5Id) {
const token = await getM2MToken()
const url = `${config.CHALLENGE_API_URL}/${v5Id}/notifications`
// logger.debug(`Get Challenge from V5 URL ${url}`)
let res = null
try {
res = await axios.post(url, {}, { headers: { Authorization: `Bearer ${token}` } })
} catch (e) {
logger.error(`Axios Error: ${JSON.stringify(e)}`)
}
// console.log(res.data)
return res.data || null
}

async function getChallengeFromV5API (legacyId) {
const token = await getM2MToken()
const url = `${config.CHALLENGE_API_URL}?legacyId=${legacyId}&perPage=1&page=1`
logger.debug(`Get Challenge from V5 URL ${url}`)
// logger.debug(`Get Challenge from V5 URL ${url}`)
let res = null
try {
res = await axios.get(url, { headers: { Authorization: `Bearer ${token}` } })
Expand Down
2 changes: 1 addition & 1 deletion src/services/resourceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async function createResourceInV5 (challengeId, memberHandle, roleId) {
}
let res = null
try {
logger.debug(`Creating Resource ${challengeId}, ${memberHandle}, ${roleId}`)
// logger.debug(`Creating Resource ${challengeId}, ${memberHandle}, ${roleId}`)
res = await axios.post(url, data, { headers: { Authorization: `Bearer ${token}` } })
} catch (e) {
logger.error(`get from v5 error ${JSON.stringify(e)}`)
Expand Down