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

Restructuring and some additional logging #103

Merged
merged 1 commit into from
Oct 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
15 changes: 15 additions & 0 deletions src/services/ProcessorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ async function recreatePhases (legacyId, v5Phases, createdBy) {
phase.duration * 1000,
createdBy
)
//Handle checkpoint phases
//Magic numbers: 15=checkpoint submission, 16=checkpoint screen, 17=checkpoint review, 1=registration
//For dependencyStart: 1=start, 0=end
if(phaseLegacyId==17){
logger.info(`Creating phase dependencies for checkpoint phases`)

registrationPhaseId = await timelineService.getProjectPhaseId(legacyId, 1)
checkpointSubmissionPhaseId = await timelineService.getProjectPhaseId(legacyId, 15)
checkpointScreeningPhaseId = await timelineService.getProjectPhaseId(legacyId, 16)
checkpointReviewPhaseId = await timelineService.getProjectPhaseId(legacyId, 17)

await timelineService.insertPhaseDependency(registrationPhaseId, checkpointSubmissionPhaseId, 1, createdBy)
await timelineService.insertPhaseDependency(checkpointSubmissionPhaseId, checkpointScreeningPhaseId, 0, createdBy)
await timelineService.insertPhaseDependency(checkpointScreeningPhaseId, checkpointReviewPhaseId, 0, createdBy)
}
} else if (!phaseLegacyId) {
logger.warn(`Could not create phase ${phase.name} on legacy!`)
}
Expand Down
18 changes: 5 additions & 13 deletions src/services/timelineService.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ async function getPhaseTypes () {
}

async function insertPhaseDependency(dependencyPhaseId, dependentPhaseId, dependencyStart, createdBy){

logger.info(`Creating phase dependency ${dependencyPhaseId} to ${dependentPhaseId} at ${dependencyStart}`)
const connection = await helper.getInformixConnection()
let result = null
try {
Expand Down Expand Up @@ -185,18 +187,6 @@ async function createPhase (challengeLegacyId, phaseTypeId, statusTypeId, schedu
])
await connection.commitTransactionAsync()

//Handle checkpoint phases
//Magic numbers: 15=checkpoint submission, 16=checkpoint screen, 17=checkpoint review, 1=registration
//For dependencyStart: 1=start, 0=end
if(phaseTypeId==17){
registrationPhaseId = await this.getProjectPhaseId(challengeLegacyId, 1)
checkpointSubmissionPhaseId = await this.getProjectPhaseId(challengeLegacyId, 15)
checkpointScreeningPhaseId = await this.getProjectPhaseId(challengeLegacyId, 16)
checkpointReviewPhaseId = await this.getProjectPhaseId(challengeLegacyId, 17)
await this.insertPhaseDependency(registrationPhaseId, checkpointSubmissionPhaseId, 1, createdBy)
await this.insertPhaseDependency(checkpointSubmissionPhaseId, checkpointScreeningPhaseId, 0, createdBy)
await this.insertPhaseDependency(checkpointScreeningPhaseId, checkpointReviewPhaseId, 0, createdBy)
}
} catch (e) {
logger.error(`Error in 'createPhase' ${e}, rolling back transaction`)
await connection.rollbackTransactionAsync()
Expand Down Expand Up @@ -291,5 +281,7 @@ module.exports = {
updatePhase,
enableTimelineNotifications,
createPhase,
dropPhase
dropPhase,
insertPhaseDependency,
getProjectPhaseId
}