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

Commit dd68b4d

Browse files
committed
feat: challenge phase extension
1 parent 344213d commit dd68b4d

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ workflows:
7070
branches:
7171
only:
7272
- develop
73+
- feat/challenge-extension
7374

7475
# Production builds are exectuted only on tagged commits to the
7576
# master branch.

src/constants.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const prizeSetTypes = {
1010
CheckPoint: 'checkpoint'
1111
}
1212

13+
const PhaseTypes = {
14+
POST_MORTEM: 12
15+
}
16+
1317
const EVENT_ORIGINATOR = 'legacy-challenge-processor'
1418

1519
const EVENT_MIME_TYPE = 'application/json'
@@ -155,5 +159,6 @@ module.exports = {
155159
challengeStatuses,
156160
PhaseStatusTypes,
157161
prizeTypesIds,
158-
supportedMetadata
162+
supportedMetadata,
163+
PhaseTypes
159164
}

src/services/ProcessorService.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,28 @@ async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService
7979
const phasesFromIFx = await timelineService.getChallengePhases(legacyId)
8080
logger.debug(`Phases from v5: ${JSON.stringify(v5Phases)}`)
8181
logger.debug(`Phases from IFX: ${JSON.stringify(phasesFromIFx)}`)
82+
83+
let isSubmissionPhaseOpen = false
84+
let postMortemPhaseId = null
8285
for (const phase of phasesFromIFx) {
86+
if (phase.phase_type_id === constants.PhaseTypes.POST_MORTEM) {
87+
postMortemPhaseId = phase.project_phase_id
88+
}
8389
const phaseName = _.get(_.find(phaseTypes, pt => pt.phase_type_id === phase.phase_type_id), 'name')
8490
const v5Equivalent = _.find(v5Phases, p => p.name === phaseName)
8591
logger.info(`v4 Phase: ${JSON.stringify(phase)}, v5 Equiv: ${JSON.stringify(v5Equivalent)}`)
8692
if (v5Equivalent) {
87-
// Compare duration and status
88-
// if (v5Equivalent.duration * 1000 !== phase.duration * 1 || isSelfService) {
89-
// ||
90-
// (v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Closed) ||
91-
// (!v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Open)) {
92-
// const newStatus = v5Equivalent.isOpen
93-
// ? constants.PhaseStatusTypes.Open
94-
// : (new Date().getTime() <= new Date(v5Equivalent.scheduledEndDate).getTime() ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
95-
// update phase
9693
logger.debug(`Will update phase ${phaseName}/${v5Equivalent.name} from ${phase.duration} to duration ${v5Equivalent.duration * 1000} milli`)
97-
const newStatus = v5Equivalent.isOpen
98-
? constants.PhaseStatusTypes.Open
99-
: (new Date().getTime() <= new Date(v5Equivalent.scheduledEndDate).getTime() ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
94+
95+
let newStatus = v5Equivalent.isOpen ? constants.PhaseStatusTypes.Open : constants.PhaseStatusTypes.Scheduled;
96+
if (v5Equivalent.scheduledEndDate != null && v5Equivalent.scheduledEndDate.trim().length > 0 && new Date().getTime() > new Date(v5Equivalent.scheduledEndDate).getTime()) {
97+
newStatus = constants.PhaseStatusTypes.Closed;
98+
}
99+
100+
if (v5Equivalent.name === 'Submission' && newStatus === constants.PhaseStatusTypes.Open) {
101+
isSubmissionPhaseOpen = true
102+
}
103+
100104
await timelineService.updatePhase(
101105
phase.project_phase_id,
102106
legacyId,
@@ -105,17 +109,18 @@ async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService
105109
v5Equivalent.duration * 1000,
106110
newStatus // phase.phase_status_id
107111
)
108-
// newStatus)
109-
// } else {
110-
// logger.info(`Durations for ${phaseName} match: ${v5Equivalent.duration * 1000} === ${phase.duration}`)
111-
// }
112112
} else {
113113
logger.info(`No v5 Equivalent Found for ${phaseName}`)
114114
}
115115
if (isSelfService && phaseName === 'Review') {
116116
// make sure to set the required reviewers to 2
117117
await createOrSetNumberOfReviewers(_.toString(phase.project_phase_id), _.toString(numOfReviewers), _.toString(createdBy))
118118
}
119+
120+
if (isSubmissionPhaseOpen && postMortemPhaseId != null) {
121+
logger.info('Submission Phase is open, Remove Post-Mortem Phase', legacyId, postMortemPhaseId)
122+
await timelineService.dropPhase(legacyId, postMortemPhaseId)
123+
}
119124
}
120125
// TODO: What about iterative reviews? There can be many for the same challenge.
121126
// TODO: handle timeline template updates

0 commit comments

Comments
 (0)