File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
cloud/functions/src/crawlers Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -373,7 +373,12 @@ const saveEvent = async function (event: FullEvent, crawlerDescriptor: z.infer<t
373373 const ratingsTalkIds = talkFeedbacksDoc . map ( doc => doc . id ) ;
374374 await Promise . all ( [
375375 ...event . daySchedules . map ( async daySchedule => {
376- const dailyRatings = ( await db . doc ( `${ resolvedEventFirestorePath ( event . id , maybeSpaceToken ) } /organizer-space/${ organizerSecretToken } /daily-ratings/${ daySchedule . day } ` ) . get ( ) ) . data ( ) as Record < string , object > ;
376+ const dailyRatingsDoc = db . doc ( `${ resolvedEventFirestorePath ( event . id , maybeSpaceToken ) } /organizer-space/${ organizerSecretToken } /daily-ratings/${ daySchedule . day } ` ) ;
377+ let dailyRatings = ( await dailyRatingsDoc . get ( ) ) . data ( ) as Record < string , object > ;
378+ if ( ! dailyRatings ) {
379+ dailyRatings = { } ;
380+ await dailyRatingsDoc . create ( dailyRatings ) ;
381+ }
377382 const talkIds = daySchedule . timeSlots . flatMap ( ts => ts . type === 'talks' ? ts . talks . map ( t => t . id ) : [ ] )
378383 const dailyRatingsToUpdate = talkIds . reduce ( ( dailyRatingsToUpdate , talkId ) => {
379384 if ( ! dailyRatings [ talkId ] ) {
@@ -383,7 +388,7 @@ const saveEvent = async function (event: FullEvent, crawlerDescriptor: z.infer<t
383388 } , { } as Record < string , object > )
384389
385390 if ( Object . keys ( dailyRatingsToUpdate ) . length ) {
386- await db . doc ( ` ${ resolvedEventFirestorePath ( event . id , maybeSpaceToken ) } /organizer-space/ ${ organizerSecretToken } /daily-ratings/ ${ daySchedule . day } ` ) . update ( dailyRatingsToUpdate ) ;
391+ await dailyRatingsDoc . update ( dailyRatingsToUpdate ) ;
387392 }
388393 } ) ,
389394 ...event . talks . map ( async talk => {
You can’t perform that action at this time.
0 commit comments