@@ -15,10 +15,10 @@ const phaseIdGen = new IDGenerator('project_phase_id_seq')
1515
1616const QUERY_GET_PHASE_TYPES = 'SELECT phase_type_id, name FROM phase_type_lu'
1717
18- 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'
18+ 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'
1919const QUERY_DROP_CHALLENGE_PHASE = 'DELETE FROM project_phase WHERE project_id = ? AND project_phase_id = ?'
2020const 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)'
21- 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'
21+ 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'
2222
2323const QUERY_DROP_CHALLENGE_PHASE_CRITERIA = 'DELETE FROM phase_criteria WHERE project_phase_id = ?'
2424
@@ -37,6 +37,9 @@ const QUERY_INSERT_CHALLENGE_PHASE_SCORECARD_ID = 'INSERT INTO phase_criteria (p
3737 * @param {String } dateStr the date in string format
3838 */
3939function formatDate ( dateStr ) {
40+ if ( ! dateStr ) {
41+ return null
42+ }
4043 const date = momentTZ . tz ( dateStr , config . TIMEZONE ) . format ( 'YYYY-MM-DD HH:mm:ss' )
4144 logger . info ( `Formatting date ${ dateStr } New Date ${ date } ` )
4245 return date
@@ -228,18 +231,19 @@ async function createPhase (challengeLegacyId, phaseTypeId, statusTypeId, schedu
228231 * Update a phase in IFX
229232 * @param {Number } phaseId the phase ID
230233 * @param {Number } challengeLegacyId the legacy challenge ID
234+ * @param {Date } fixedStartTime the fixed start date
231235 * @param {Date } startTime the scheduled start date
232236 * @param {Date } endTime the scheduled end date
233237 * @param {Date } duration the duration
234238 * @param {Number } statusTypeId the status type ID
235239 */
236- async function updatePhase ( phaseId , challengeLegacyId , startTime , endTime , duration , statusTypeId ) {
240+ async function updatePhase ( phaseId , challengeLegacyId , fixedStartTime , startTime , endTime , duration , statusTypeId ) {
237241 const connection = await helper . getInformixConnection ( )
238242 let result = null
239243 try {
240244 // await connection.beginTransactionAsync()
241245 const query = await prepare ( connection , util . format ( QUERY_UPDATE_CHALLENGE_PHASE , phaseId , challengeLegacyId ) )
242- result = await query . executeAsync ( [ formatDate ( startTime ) , formatDate ( endTime ) , duration , statusTypeId ] )
246+ result = await query . executeAsync ( [ formatDate ( fixedStartTime ) , formatDate ( startTime ) , formatDate ( endTime ) , duration , statusTypeId ] )
243247 // await connection.commitTransactionAsync()
244248 } catch ( e ) {
245249 logger . error ( `Error in 'updatePhase' ${ e } , rolling back transaction` )
0 commit comments