Skip to content

Commit 89884ac

Browse files
author
Vikas Agarwal
committed
Fixing wrong handling of transactions in timelines model. Create was fixed before and update is not using transactions as of now which is a separate issue to fix.
1 parent 387aa4b commit 89884ac

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/routes/timelines/delete.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ module.exports = [
3333
.then(() => timeline.destroy())
3434
// Cascade delete the milestones
3535
.then(() => models.Milestone.update({ deletedBy: req.authUser.userId }, { where: { timelineId: timeline.id } }))
36-
.then(() => models.Milestone.destroy({ where: { timelineId: timeline.id } }))
37-
.then(() => {
38-
// Send event to bus
39-
req.log.debug('Sending event to RabbitMQ bus for timeline %d', deleted.id);
40-
req.app.services.pubsub.publish(EVENT.ROUTING_KEY.TIMELINE_REMOVED,
41-
deleted,
42-
{ correlationId: req.id },
43-
);
36+
.then(() => models.Milestone.destroy({ where: { timelineId: timeline.id } })),
37+
)
38+
.then(() => {
39+
// Send event to bus
40+
req.log.debug('Sending event to RabbitMQ bus for timeline %d', deleted.id);
41+
req.app.services.pubsub.publish(EVENT.ROUTING_KEY.TIMELINE_REMOVED,
42+
deleted,
43+
{ correlationId: req.id },
44+
);
4445

45-
// Write to response
46-
res.status(204).end();
47-
return Promise.resolve();
48-
})
49-
.catch(next),
50-
);
46+
// Write to response
47+
res.status(204).end();
48+
return Promise.resolve();
49+
})
50+
.catch(next);
5151
},
5252
];

0 commit comments

Comments
 (0)