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

Commit

Permalink
Merge pull request #76 from topcoder-platform/develop
Browse files Browse the repository at this point in the history
Prod release
  • Loading branch information
ThomasKranitsas authored Apr 5, 2022
2 parents d600cd6 + c7b1e4e commit 2bbd2a1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
2 changes: 2 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ module.exports = {
SYNC_V5_TERM_UUID: process.env.SYNC_V5_TERM_UUID || '317cd8f9-d66c-4f2a-8774-63c612d99cd4',
SYNC_V5_WRITE_ENABLED: process.env.SYNC_V5_WRITE_ENABLED === 'true' || false,

DEV_TRACK_ID: '9b6fc876-f4d9-4ccb-9dfd-419247628825',

TIMEZONE: process.env.TIMEZONE || 'America/New_York',

IGNORED_ORIGINATORS: process.env.IGNORED_ORIGINATORS ? process.env.IGNORED_ORIGINATORS.split(',') : ['legacy-migration-script']
Expand Down
49 changes: 25 additions & 24 deletions src/services/ProcessorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function recreatePhases (legacyId, v5Phases, createdBy) {
* @param {Boolean} isSelfService is the challenge self-service
* @param {String} createdBy the created by
*/
async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService) {
async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService, numOfReviewers) {
const phaseTypes = await timelineService.getPhaseTypes()
const phasesFromIFx = await timelineService.getChallengePhases(legacyId)
logger.debug(`Phases from v5: ${JSON.stringify(v5Phases)}`)
Expand All @@ -84,33 +84,33 @@ async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService
logger.info(`v4 Phase: ${JSON.stringify(phase)}, v5 Equiv: ${JSON.stringify(v5Equivalent)}`)
if (v5Equivalent) {
// Compare duration and status
if (v5Equivalent.duration * 1000 !== phase.duration * 1 || isSelfService) {
// ||
// (v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Closed) ||
// (!v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Open)) {
// const newStatus = v5Equivalent.isOpen
// ? constants.PhaseStatusTypes.Open
// : (new Date().getTime() <= new Date(v5Equivalent.scheduledEndDate).getTime() ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
// update phase
logger.debug(`Will update phase ${phaseName}/${v5Equivalent.name} from ${phase.duration} to duration ${v5Equivalent.duration * 1000} milli`)
await timelineService.updatePhase(
phase.project_phase_id,
legacyId,
v5Equivalent.scheduledStartDate,
v5Equivalent.scheduledEndDate,
v5Equivalent.duration * 1000,
phase.phase_status_id
)
// newStatus)
} else {
logger.info(`Durations for ${phaseName} match: ${v5Equivalent.duration * 1000} === ${phase.duration}`)
}
// if (v5Equivalent.duration * 1000 !== phase.duration * 1 || isSelfService) {
// ||
// (v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Closed) ||
// (!v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Open)) {
// const newStatus = v5Equivalent.isOpen
// ? constants.PhaseStatusTypes.Open
// : (new Date().getTime() <= new Date(v5Equivalent.scheduledEndDate).getTime() ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
// update phase
logger.debug(`Will update phase ${phaseName}/${v5Equivalent.name} from ${phase.duration} to duration ${v5Equivalent.duration * 1000} milli`)
await timelineService.updatePhase(
phase.project_phase_id,
legacyId,
v5Equivalent.scheduledStartDate,
v5Equivalent.scheduledEndDate,
v5Equivalent.duration * 1000,
phase.phase_status_id
)
// newStatus)
// } else {
// logger.info(`Durations for ${phaseName} match: ${v5Equivalent.duration * 1000} === ${phase.duration}`)
// }
} else {
logger.info(`No v5 Equivalent Found for ${phaseName}`)
}
if (isSelfService && phaseName === 'Review') {
// make sure to set the required reviewers to 2
await createOrSetNumberOfReviewers(_.toString(phase.project_phase_id), '2', _.toString(createdBy))
await createOrSetNumberOfReviewers(_.toString(phase.project_phase_id), _.toString(numOfReviewers), _.toString(createdBy))
}
}
// TODO: What about iterative reviews? There can be many for the same challenge.
Expand Down Expand Up @@ -709,7 +709,8 @@ async function processMessage (message) {
}

if (!_.get(message.payload, 'task.isTask')) {
await syncChallengePhases(legacyId, message.payload.phases, createdByUserId, _.get(message, 'payload.legacy.selfService'))
const numOfReviewers = 2
await syncChallengePhases(legacyId, message.payload.phases, createdByUserId, _.get(message, 'payload.legacy.selfService'), numOfReviewers)
} else {
logger.info('Will skip syncing phases as the challenge is a task...')
}
Expand Down

0 comments on commit 2bbd2a1

Please sign in to comment.