@@ -9,6 +9,7 @@ const helper = require('../common/helper')
9
9
const QUERY_GET_PHASE_TYPES = 'SELECT phase_type_id, name FROM phase_type_lu'
10
10
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'
11
11
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'
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)'
12
13
13
14
/**
14
15
* Prepare Informix statement
@@ -85,8 +86,33 @@ async function updatePhase (phaseId, challengeLegacyId, startTime, endTime, dura
85
86
return result
86
87
}
87
88
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
+
88
113
module . exports = {
89
114
getChallengePhases,
90
115
getPhaseTypes,
91
- updatePhase
116
+ updatePhase,
117
+ enableTimelineNotifications
92
118
}
0 commit comments