Skip to content

Commit 68a9c03

Browse files
author
Vikas Agarwal
committed
Raised phase progress event when milestone completed
1 parent 4f0ce2e commit 68a9c03

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/events/busApi.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -428,25 +428,28 @@ module.exports = (app, logger) => {
428428
logger.debug('sendMilestoneNotification', original, updated);
429429
// Send transition events
430430
if (original.status !== updated.status) {
431-
let event;
431+
let events;
432432
if (updated.status === MILESTONE_STATUS.COMPLETED) {
433-
event = BUS_API_EVENT.MILESTONE_TRANSITION_COMPLETED;
433+
// on milestone completion, raise milestone completion and project phase progress events
434+
events = [BUS_API_EVENT.MILESTONE_TRANSITION_COMPLETED, BUS_API_EVENT.PROJECT_PHASE_UPDATE_PROGRESS];
434435
} else if (updated.status === MILESTONE_STATUS.ACTIVE) {
435-
event = BUS_API_EVENT.MILESTONE_TRANSITION_ACTIVE;
436+
events = [BUS_API_EVENT.MILESTONE_TRANSITION_ACTIVE];
436437
}
437438

438-
if (event) {
439-
createEvent(event, {
440-
projectId: project.id,
441-
projectName: project.name,
442-
projectUrl: connectProjectUrl(project.id),
443-
timelineId: req.timeline.id,
444-
timelineName: req.timeline.name,
445-
originalMilestone: original,
446-
updatedMilestone: updated,
447-
userId: req.authUser.userId,
448-
initiatorUserId: req.authUser.userId,
449-
}, logger);
439+
if (events) {
440+
events.forEach(event => {
441+
createEvent(event, {
442+
projectId: project.id,
443+
projectName: project.name,
444+
projectUrl: connectProjectUrl(project.id),
445+
timelineId: req.timeline.id,
446+
timelineName: req.timeline.name,
447+
originalMilestone: original,
448+
updatedMilestone: updated,
449+
userId: req.authUser.userId,
450+
initiatorUserId: req.authUser.userId,
451+
}, logger);
452+
});
450453
}
451454
}
452455

0 commit comments

Comments
 (0)