Skip to content

Commit 2fbbef5

Browse files
committed
wip
1 parent 0a7b197 commit 2fbbef5

File tree

9 files changed

+33
-25
lines changed

9 files changed

+33
-25
lines changed

packages/corelib/src/dataModel/PieceInstance.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ export interface PieceInstance {
5151

5252
piece: PieceInstancePiece
5353

54-
// owner: 'part' | 'rundown'
55-
5654
/** A flag to signal a given Piece has been deactivated manually */
5755
disabled?: boolean
5856

packages/job-worker/src/blueprints/context/services/PartAndPieceInstanceActionService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ export async function applyActionSideEffects(
528528
await syncPlayheadInfinitesForNextPartInstance(
529529
context,
530530
playoutModel,
531+
undefined,
531532
playoutModel.currentPartInstance,
532533
playoutModel.nextPartInstance
533534
)

packages/job-worker/src/ingest/syncChangesToPartInstance.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type SyncedInstance = {
4848
* This defers out to the Blueprints to do the syncing
4949
* @param context Context of the job ebeing run
5050
* @param playoutModel Playout model containing containing the Rundown being ingested
51-
* @param ingestModel Ingest model for the Rundown
51+
* @param ingestModel Ingest model for the Rundown. This is being written to mongodb while this method runs
5252
*/
5353
export async function syncChangesToPartInstances(
5454
context: JobContext,
@@ -243,6 +243,7 @@ export async function syncChangesToPartInstances(
243243
await syncPlayheadInfinitesForNextPartInstance(
244244
context,
245245
playoutModel,
246+
ingestModel,
246247
playoutModel.currentPartInstance,
247248
playoutModel.nextPartInstance
248249
)

packages/job-worker/src/playout/adlibJobs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ async function pieceTakeNowAsAdlib(
194194
await syncPlayheadInfinitesForNextPartInstance(
195195
context,
196196
playoutModel,
197+
undefined,
197198
playoutModel.currentPartInstance,
198199
playoutModel.nextPartInstance
199200
)
@@ -373,6 +374,7 @@ export async function handleStopPiecesOnSourceLayers(
373374
await syncPlayheadInfinitesForNextPartInstance(
374375
context,
375376
playoutModel,
377+
undefined,
376378
playoutModel.currentPartInstance,
377379
playoutModel.nextPartInstance
378380
)

packages/job-worker/src/playout/adlibUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export async function innerStartOrQueueAdLibPiece(
6969
await syncPlayheadInfinitesForNextPartInstance(
7070
context,
7171
playoutModel,
72+
undefined,
7273
currentPartInstance,
7374
playoutModel.nextPartInstance
7475
)

packages/job-worker/src/playout/debug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export async function handleDebugSyncPlayheadInfinitesForNextPartInstance(
2525
await syncPlayheadInfinitesForNextPartInstance(
2626
context,
2727
playoutModel,
28+
undefined,
2829
playoutModel.currentPartInstance,
2930
playoutModel.nextPartInstance
3031
)

packages/job-worker/src/playout/infinites.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ export async function fetchPiecesThatMayBeActiveForPart(
220220
export async function syncPlayheadInfinitesForNextPartInstance(
221221
context: JobContext,
222222
playoutModel: PlayoutModel,
223+
unsavedIngestModel: Pick<IngestModelReadonly, 'rundownId' | 'getAllPieces'> | undefined,
223224
fromPartInstance: PlayoutPartInstanceModel | null,
224225
toPartInstance: PlayoutPartInstanceModel | null
225226
): Promise<void> {
@@ -293,6 +294,7 @@ export async function syncPlayheadInfinitesForNextPartInstance(
293294
const baselineInfinites = await getBaselineInfinitesForPart(
294295
context,
295296
playoutModel,
297+
unsavedIngestModel,
296298
toPartInstance.partInstance.part,
297299
toPartInstance.partInstance._id
298300
)
@@ -403,17 +405,18 @@ export function getPieceInstancesForPart(
403405
export async function getBaselineInfinitesForPart(
404406
context: JobContext,
405407
playoutModel: PlayoutModel,
406-
// unsavedIngestModel: Pick<IngestModelReadonly, 'rundownId' | 'getAllPieces'> | undefined,
408+
unsavedIngestModel: Pick<IngestModelReadonly, 'rundownId' | 'getAllPieces'> | undefined,
407409
part: ReadonlyDeep<DBPart>,
408410
partInstanceId: PartInstanceId
409411
): Promise<PieceInstance[]> {
410-
// nocommit - will this ever need to consider an unsaved ingest model?
411-
412-
// Find the pieces
413-
const pieces = await context.directCollections.Pieces.findFetch({
414-
startRundownId: part.rundownId,
415-
startPartId: null,
416-
})
412+
// Find the pieces. If an ingest model is provided, use that instead of the database
413+
const pieces =
414+
unsavedIngestModel && unsavedIngestModel.rundownId === part.rundownId
415+
? unsavedIngestModel.getAllPieces().filter((p) => p.startPartId === null)
416+
: await context.directCollections.Pieces.findFetch({
417+
startRundownId: part.rundownId,
418+
startPartId: null,
419+
})
417420

418421
const playlistActivationId = playoutModel.playlist.activationId
419422
if (!playlistActivationId) throw new Error(`RundownPlaylist "${playoutModel.playlistId}" is not active`)

packages/job-worker/src/playout/setNext.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ async function prepareExistingPartInstanceForBeingNexted(
275275
playoutModel: PlayoutModel,
276276
instance: PlayoutPartInstanceModel
277277
): Promise<PlayoutPartInstanceModel> {
278-
await syncPlayheadInfinitesForNextPartInstance(context, playoutModel, playoutModel.currentPartInstance, instance)
278+
await syncPlayheadInfinitesForNextPartInstance(
279+
context,
280+
playoutModel,
281+
undefined, // Any ingest model must have been fully written before we get here
282+
playoutModel.currentPartInstance,
283+
instance
284+
)
279285

280286
return instance
281287
}
@@ -304,7 +310,13 @@ async function preparePartInstanceForPartBeingNexted(
304310

305311
if (currentPartInstance === null) {
306312
// This is the first take of the rundown, ensure the baseline infinites are loaded
307-
const baselineInfinites = await getBaselineInfinitesForPart(context, playoutModel, nextPart, partInstanceId)
313+
const baselineInfinites = await getBaselineInfinitesForPart(
314+
context,
315+
playoutModel,
316+
undefined, // Any ingest model must have been fully written before we get here
317+
nextPart,
318+
partInstanceId
319+
)
308320
newPieceInstances.push(...baselineInfinites)
309321
}
310322

packages/job-worker/src/playout/timeline/rundown.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,7 @@ function calculateInfinitePieceEnable(
364364
infiniteGroupEnable = { start: infiniteGroupStart }
365365
pieceEnable.start = 0
366366

367-
// nocommit prerollDuration?
368-
369-
// // If an end time has been set by a hotkey, then update the duration to be correct
370-
// if (pieceInstance.userDuration && pieceInstance.piece.enable.start !== 'now') {
371-
// if ('endRelativeToNow' in pieceInstance.userDuration) {
372-
// infiniteGroupEnable.duration =
373-
// pieceInstance.userDuration.endRelativeToNow - pieceInstance.piece.enable.start
374-
// } else {
375-
// // This should never be hit
376-
// infiniteGroupEnable.end = 'now'
377-
// }
378-
// }
367+
// Future: should this consider the prerollDuration?
379368
} else if (pieceInstance.plannedStartedPlayback !== undefined) {
380369
// We have a absolute start time, so we should use that.
381370
let infiniteGroupStart = pieceInstance.plannedStartedPlayback

0 commit comments

Comments
 (0)