Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit ee7956c

Browse files
enable timeline notifications
1 parent d970922 commit ee7956c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/services/ProcessorService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ async function processCreate (message) {
458458
for (const resource of (challengeResourcesResponse.body || [])) {
459459
await helper.postBusEvent(config.RESOURCE_CREATE_TOPIC, _.pick(resource, ['id', 'challengeId', 'memberId', 'memberHandle', 'roleId', 'created', 'createdBy', 'updated', 'updatedBy', 'legacyId']))
460460
}
461+
await timelineService.enableTimelineNotifications(newChallenge.body.result.content.id, _.get(message, 'payload.createdBy'))
461462
logger.debug('End of processCreate')
462463
} catch (e) {
463464
logger.error('processCreate Catch', e)

src/services/timelineService.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const helper = require('../common/helper')
99
const QUERY_GET_PHASE_TYPES = 'SELECT phase_type_id, name FROM phase_type_lu'
1010
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'
1111
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)'
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+
88113
module.exports = {
89114
getChallengePhases,
90115
getPhaseTypes,
91-
updatePhase
116+
updatePhase,
117+
enableTimelineNotifications
92118
}

0 commit comments

Comments
 (0)