@@ -299,10 +299,27 @@ class EventsFactory extends Factory {
299299 lastEvent = result . pop ( ) ;
300300 }
301301
302+ const composedResult = result . map ( dailyEvent => {
303+ const repetition = dailyEvent . repetition ;
304+ const event = dailyEvent . event ;
305+
306+ console . log ( 'current projectId is ' , this . projectId ) ;
307+
308+ return {
309+ ...dailyEvent ,
310+ id : dailyEvent . _id . toString ( ) ,
311+ _id : undefined ,
312+ event : this . _composeEventWithRepetition ( event , repetition ) ,
313+ repetition : undefined ,
314+ }
315+ } )
316+
317+ console . log ( 'result' , composedResult )
318+
302319
303320 return {
304321 nextCursor : lastEvent ? lastEvent . _id . toString ( ) : null ,
305- dailyEvents : result ,
322+ dailyEvents : composedResult ,
306323 } ;
307324 }
308325
@@ -679,6 +696,8 @@ class EventsFactory extends Factory {
679696 _id : new ObjectID ( eventId ) ,
680697 } ) ;
681698
699+ console . log ( 'repetition found' , repetition )
700+
682701 /**
683702 * If repetition is not found by eventId, try to find it by eventId
684703 */
@@ -687,11 +706,15 @@ class EventsFactory extends Factory {
687706 . findOne ( {
688707 _id : new ObjectID ( eventId ) ,
689708 } ) ;
709+
710+ console . log ( 'no repetition found, fetched by original event id' , originalEvent ) ;
690711 } else {
691712 originalEvent = await this . getCollection ( this . TYPES . EVENTS )
692713 . findOne ( {
693714 groupHash : repetition . groupHash ,
694715 } ) ;
716+
717+ console . log ( 'repetition found, fetched by groupHash' , originalEvent ) ;
695718 }
696719
697720 return originalEvent ;
@@ -711,6 +734,7 @@ class EventsFactory extends Factory {
711734 firstAppearanceTimestamp : event . timestamp ,
712735 timestamp : repetition . timestamp ,
713736 payload : composeEventPayloadWithRepetition ( event . payload , repetition ) ,
737+ projectId : this . projectId ,
714738 } ;
715739 }
716740}
0 commit comments