Skip to content

Commit d3d61a0

Browse files
committed
fix original event without repetition in project overview
1 parent ffd9040 commit d3d61a0

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/models/eventsFactory.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ class EventsFactory extends Factory {
297297
$unwind: '$event',
298298
},
299299
{
300-
$unwind: '$repetition',
300+
$unwind: {
301+
path: '$repetition',
302+
preserveNullAndEmptyArrays: true,
303+
},
301304
},
302305
{
303306
$match: {
@@ -324,7 +327,21 @@ class EventsFactory extends Factory {
324327
const repetition = dailyEvent.repetition;
325328
const event = dailyEvent.event;
326329

327-
dailyEvent.event = this._composeEventWithRepetition(event, repetition);
330+
/**
331+
* In case of repetition we need to compose event with repetition
332+
* Otherwise we need to put original event with originalTimestamp and originalEventId
333+
*/
334+
if (repetition) {
335+
dailyEvent.event = this._composeEventWithRepetition(event, repetition);
336+
} else {
337+
dailyEvent.event = {
338+
...event,
339+
originalTimestamp: event.timestamp,
340+
originalEventId: event._id,
341+
projectId: this.projectId,
342+
};
343+
}
344+
328345
dailyEvent.id = dailyEvent._id.toString();
329346

330347
delete dailyEvent.repetition;

0 commit comments

Comments
 (0)