@@ -23,6 +23,7 @@ import { PlayoutModel, PlayoutModelPreInit } from '../PlayoutModel'
2323import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
2424import { RundownBaselineObj } from '@sofie-automation/corelib/dist/dataModel/RundownBaselineObj'
2525import { sortRundownsWithinPlaylist } from '@sofie-automation/corelib/dist/playout/playlist'
26+ import { logger } from '../../../logging'
2627
2728/**
2829 * Load a PlayoutModelPreInit for the given RundownPlaylist
@@ -188,7 +189,7 @@ async function loadRundowns(
188189 context . directCollections . Segments . findFetch ( {
189190 $or : [
190191 {
191- // In a different rundown
192+ // Either in rundown when ingestModel === null or not available in ingestModel
192193 rundownId : { $in : loadRundownIds } ,
193194 } ,
194195 {
@@ -233,14 +234,25 @@ async function loadRundowns(
233234 }
234235 }
235236
236- return rundowns . map (
237- ( rundown ) =>
238- new PlayoutRundownModelImpl (
239- rundown ,
240- groupedSegmentsWithParts . get ( rundown . _id ) ?? [ ] ,
241- groupedBaselineObjects . get ( rundown . _id ) ?? [ ]
237+ return rundowns . map ( ( rundown ) => {
238+ const groupedSegmentsWithPartsForRundown = groupedSegmentsWithParts . get ( rundown . _id )
239+ if ( ! groupedSegmentsWithPartsForRundown ) {
240+ logger . debug (
241+ `groupedSegmentsWithPartsForRundown for Rundown "${ rundown . _id } " is undefined (has the rundown no segments?)`
242242 )
243- )
243+ }
244+ const groupedBaselineObjectsForRundown = groupedBaselineObjects . get ( rundown . _id )
245+ if ( ! groupedBaselineObjectsForRundown )
246+ logger . debug (
247+ `groupedBaselineObjectsForRundown for Rundown "${ rundown . _id } " is undefined (has the rundown no baseline objects?)`
248+ )
249+
250+ return new PlayoutRundownModelImpl (
251+ rundown ,
252+ groupedSegmentsWithPartsForRundown ?? [ ] ,
253+ groupedBaselineObjectsForRundown ?? [ ]
254+ )
255+ } )
244256}
245257
246258async function loadPartInstances (
0 commit comments