Skip to content

Commit 1f82fd0

Browse files
committed
fix: updating timeline in ES index on milestone updates
1 parent 19460ed commit 1f82fd0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/events/milestones/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ const milestoneUpdatedHandler = Promise.coroutine(function* (logger, msg, channe
8282
});
8383
}
8484

85-
let cTimeline = null;
86-
// if timeline is modified
87-
if (data.cascadedUpdates && data.cascadedUpdates.timeline) {
88-
cTimeline = data.cascadedUpdates.timeline;
85+
let updatedTimeline = doc._source; // eslint-disable-line no-underscore-dangle
86+
// if timeline has been modified during milestones updates
87+
if (data.cascadedUpdates && data.cascadedUpdates.timeline && data.cascadedUpdates.timeline.updated) {
88+
// merge updated timeline with the object in ES index, the same way as we do when updating timeline in ES using timeline endpoints
89+
updatedTimeline = _.merge(doc._source, data.cascadedUpdates.timeline.updated); // eslint-disable-line no-underscore-dangle
8990
}
9091

91-
const merged = _.assign(doc._source, cTimeline, { milestones }); // eslint-disable-line no-underscore-dangle
92+
const merged = _.assign(updatedTimeline, { milestones });
9293
yield eClient.update({
9394
index: ES_TIMELINE_INDEX,
9495
type: ES_TIMELINE_TYPE,

0 commit comments

Comments
 (0)