File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments