@@ -19,6 +19,7 @@ const QUERY_GET_CHALLENGE_PHASES = 'SELECT project_phase_id, fixed_start_time, s
19
19
const QUERY_DROP_CHALLENGE_PHASE = 'DELETE FROM project_phase WHERE project_id = ? AND project_phase_id = ?'
20
20
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)'
21
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'
22
+ const QUERY_UPDATE_CHALLENGE_PHASE_WITH_START_TIME = 'UPDATE project_phase SET fixed_start_time = ?, scheduled_start_time = ?, scheduled_end_time = ?, duration = ?, phase_status_id = ?, actual_start_time = ? WHERE project_phase_id = %d and project_id = %d'
22
23
23
24
const QUERY_DROP_CHALLENGE_PHASE_CRITERIA = 'DELETE FROM phase_criteria WHERE project_phase_id = ?'
24
25
@@ -237,13 +238,19 @@ async function createPhase (challengeLegacyId, phaseTypeId, statusTypeId, schedu
237
238
* @param {Date } duration the duration
238
239
* @param {Number } statusTypeId the status type ID
239
240
*/
240
- async function updatePhase ( phaseId , challengeLegacyId , fixedStartTime , startTime , endTime , duration , statusTypeId ) {
241
+ async function updatePhase ( phaseId , challengeLegacyId , fixedStartTime , startTime , endTime , duration , statusTypeId , actualStartTime ) {
241
242
const connection = await helper . getInformixConnection ( )
242
243
let result = null
243
244
try {
244
245
// await connection.beginTransactionAsync()
245
- const query = await prepare ( connection , util . format ( QUERY_UPDATE_CHALLENGE_PHASE , phaseId , challengeLegacyId ) )
246
- result = await query . executeAsync ( [ formatDate ( fixedStartTime ) , formatDate ( startTime ) , formatDate ( endTime ) , duration , statusTypeId ] )
246
+ const query = actualStartTime == null ?
247
+ await prepare ( connection , util . format ( QUERY_UPDATE_CHALLENGE_PHASE , phaseId , challengeLegacyId ) ) :
248
+ await prepare ( connection , util . format ( QUERY_UPDATE_CHALLENGE_PHASE_WITH_START_TIME , phaseId , challengeLegacyId ) )
249
+
250
+ result = actualStartTime == null ?
251
+ await query . executeAsync ( [ formatDate ( fixedStartTime ) , formatDate ( startTime ) , formatDate ( endTime ) , duration , statusTypeId ] ) :
252
+ await query . executeAsync ( [ formatDate ( fixedStartTime ) , formatDate ( startTime ) , formatDate ( endTime ) , duration , statusTypeId , formatDate ( actualStartTime ) ] )
253
+
247
254
// await connection.commitTransactionAsync()
248
255
} catch ( e ) {
249
256
logger . error ( `Error in 'updatePhase' ${ e } , rolling back transaction` )
0 commit comments