From 46b758cfd2d3cdae48460f4457af63c921ecea43 Mon Sep 17 00:00:00 2001 From: eisbilir Date: Thu, 1 Dec 2022 17:38:10 +0300 Subject: [PATCH] update fixed_start_time --- src/services/ProcessorService.js | 1 + src/services/timelineService.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/services/ProcessorService.js b/src/services/ProcessorService.js index 271a9a3..1856046 100644 --- a/src/services/ProcessorService.js +++ b/src/services/ProcessorService.js @@ -125,6 +125,7 @@ async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService await timelineService.updatePhase( phase.project_phase_id, legacyId, + phase.fixed_start_time ? v5Equivalent.scheduledStartDate : null, v5Equivalent.scheduledStartDate, v5Equivalent.scheduledEndDate, v5Equivalent.duration * 1000, diff --git a/src/services/timelineService.js b/src/services/timelineService.js index f6a88f9..fb8a2bf 100644 --- a/src/services/timelineService.js +++ b/src/services/timelineService.js @@ -15,10 +15,10 @@ const phaseIdGen = new IDGenerator('project_phase_id_seq') const QUERY_GET_PHASE_TYPES = 'SELECT phase_type_id, name FROM phase_type_lu' -const QUERY_GET_CHALLENGE_PHASES = 'SELECT project_phase_id, scheduled_start_time, scheduled_end_time, duration, phase_status_id, phase_type_id FROM project_phase WHERE project_id = %d' +const QUERY_GET_CHALLENGE_PHASES = 'SELECT project_phase_id, fixed_start_time, scheduled_start_time, scheduled_end_time, duration, phase_status_id, phase_type_id FROM project_phase WHERE project_id = %d' const QUERY_DROP_CHALLENGE_PHASE = 'DELETE FROM project_phase WHERE project_id = ? AND project_phase_id = ?' const QUERY_INSERT_CHALLENGE_PHASE = 'INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, CURRENT, ?, CURRENT)' -const QUERY_UPDATE_CHALLENGE_PHASE = 'UPDATE project_phase SET scheduled_start_time = ?, scheduled_end_time = ?, duration = ?, phase_status_id = ? WHERE project_phase_id = %d and project_id = %d' +const QUERY_UPDATE_CHALLENGE_PHASE = 'UPDATE project_phase SET fixed_start_time = ?, scheduled_start_time = ?, scheduled_end_time = ?, duration = ?, phase_status_id = ? WHERE project_phase_id = %d and project_id = %d' const QUERY_DROP_CHALLENGE_PHASE_CRITERIA = 'DELETE FROM phase_criteria WHERE project_phase_id = ?' @@ -37,6 +37,9 @@ const QUERY_INSERT_CHALLENGE_PHASE_SCORECARD_ID = 'INSERT INTO phase_criteria (p * @param {String} dateStr the date in string format */ function formatDate (dateStr) { + if (!dateStr) { + return null + } const date = momentTZ.tz(dateStr, config.TIMEZONE).format('YYYY-MM-DD HH:mm:ss') logger.info(`Formatting date ${dateStr} New Date ${date}`) return date @@ -228,18 +231,19 @@ async function createPhase (challengeLegacyId, phaseTypeId, statusTypeId, schedu * Update a phase in IFX * @param {Number} phaseId the phase ID * @param {Number} challengeLegacyId the legacy challenge ID + * @param {Date} fixedStartTime the fixed start date * @param {Date} startTime the scheduled start date * @param {Date} endTime the scheduled end date * @param {Date} duration the duration * @param {Number} statusTypeId the status type ID */ -async function updatePhase (phaseId, challengeLegacyId, startTime, endTime, duration, statusTypeId) { +async function updatePhase (phaseId, challengeLegacyId, fixedStartTime, startTime, endTime, duration, statusTypeId) { const connection = await helper.getInformixConnection() let result = null try { // await connection.beginTransactionAsync() const query = await prepare(connection, util.format(QUERY_UPDATE_CHALLENGE_PHASE, phaseId, challengeLegacyId)) - result = await query.executeAsync([formatDate(startTime), formatDate(endTime), duration, statusTypeId]) + result = await query.executeAsync([formatDate(fixedStartTime), formatDate(startTime), formatDate(endTime), duration, statusTypeId]) // await connection.commitTransactionAsync() } catch (e) { logger.error(`Error in 'updatePhase' ${e}, rolling back transaction`)