File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -424,8 +424,14 @@ class EventsFactory extends Factory {
424424 } ;
425425 }
426426
427- let dailyEventsCursor = await this . getCollection ( this . TYPES . DAILY_EVENTS )
428- . find ( options , { projection : { lastRepetitionTime : 1 , groupingTimestamp : 1 , count : 1 } } )
427+ const dailyEventsCursor = await this . getCollection ( this . TYPES . DAILY_EVENTS )
428+ . find ( options , {
429+ projection : {
430+ lastRepetitionTime : 1 ,
431+ groupingTimestamp : 1 ,
432+ count : 1 ,
433+ } ,
434+ } )
429435 . batchSize ( MAX_DB_READ_BATCH_SIZE ) ;
430436
431437 const groupedCounts = { } ;
@@ -439,6 +445,7 @@ class EventsFactory extends Factory {
439445
440446 const key = `groupingTimestamp:${ groupingTimestamp } ` ;
441447 const current = groupedCounts [ key ] || 0 ;
448+
442449 if ( item . count === undefined || item . count === null ) {
443450 console . warn ( `Missing 'count' field for daily event with key ${ key } . Defaulting to 0.` ) ;
444451 groupedCounts [ key ] = current ;
@@ -447,7 +454,6 @@ class EventsFactory extends Factory {
447454 }
448455 }
449456
450-
451457 /**
452458 * Now fill all requested days
453459 */
@@ -458,9 +464,15 @@ class EventsFactory extends Factory {
458464 const day = new Date ( now . setDate ( now . getDate ( ) - i ) ) ;
459465 const dayMidnight = getUTCMidnight ( day ) / 1000 ;
460466
467+ let groupedCount = groupedCounts [ `groupingTimestamp:${ dayMidnight } ` ] ;
468+
469+ if ( ! groupedCount ) {
470+ groupedCount = 0 ;
471+ }
472+
461473 result . push ( {
462474 timestamp : dayMidnight ,
463- count : groupedCounts [ `groupingTimestamp: ${ dayMidnight } ` ] ?? 0 ,
475+ count : groupedCount ,
464476 } ) ;
465477 }
466478
You can’t perform that action at this time.
0 commit comments