@@ -9,6 +9,7 @@ const helper = require('../common/helper')
99const QUERY_GET_PHASE_TYPES = 'SELECT phase_type_id, name FROM phase_type_lu'
1010const 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'
1111const 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'
12+ const QUERY_ENABLE_TIMELINE_NOTIFICATIONS = 'INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) VALUES (?, "11", "On", ?, CURRENT, ?, CURRENT)'
1213
1314/**
1415 * Prepare Informix statement
@@ -85,8 +86,33 @@ async function updatePhase (phaseId, challengeLegacyId, startTime, endTime, dura
8586 return result
8687}
8788
89+ /**
90+ * Enable timeline notifications
91+ * @param {Number } challengeLegacyId the legacy challenge ID
92+ * @param {String } createdBy the created by
93+ */
94+ async function enableTimelineNotifications ( challengeLegacyId , createdBy ) {
95+ const connection = await helper . getInformixConnection ( )
96+ let result = null
97+ try {
98+ // await connection.beginTransactionAsync()
99+ const query = await prepare ( connection , QUERY_ENABLE_TIMELINE_NOTIFICATIONS )
100+ result = await query . executeAsync ( [ challengeLegacyId , createdBy , createdBy ] )
101+ // await connection.commitTransactionAsync()
102+ } catch ( e ) {
103+ logger . error ( `Error in 'enableTimelineNotifications' ${ e } , rolling back transaction` )
104+ await connection . rollbackTransactionAsync ( )
105+ throw e
106+ } finally {
107+ logger . info ( `Notifications have been enabled for challenge ${ challengeLegacyId } ` )
108+ await connection . closeAsync ( )
109+ }
110+ return result
111+ }
112+
88113module . exports = {
89114 getChallengePhases,
90115 getPhaseTypes,
91- updatePhase
116+ updatePhase,
117+ enableTimelineNotifications
92118}
0 commit comments