Skip to content

Commit 1db5059

Browse files
authored
Merge pull request Sofie-Automation#1488 from bbc/upstream/fix/infinite-pieceinstance-has-nopackage-statuses
2 parents 336ac7e + cd0cb1f commit 1db5059

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ export type PieceContentStatusPiece = Pick<
198198
'_id' | 'content' | 'expectedPackages' | 'name'
199199
> & {
200200
pieceInstanceId?: PieceInstanceId
201+
/**
202+
* If this is an infinite continuation, check the previous PieceInstance to fill the gap when package-manager has not processed an adlibbed part
203+
*/
204+
previousPieceInstanceId?: PieceInstanceId
201205
}
202206
export interface PieceContentStatusStudio
203207
extends Pick<DBStudio, '_id' | 'previewContainerIds' | 'thumbnailContainerIds'> {
@@ -656,6 +660,13 @@ async function checkPieceContentExpectedPackageStatus(
656660
if (piece.pieceInstanceId) {
657661
// If this is a PieceInstance, try looking up the PieceInstance first
658662
expectedPackageIds.unshift(getExpectedPackageId(piece.pieceInstanceId, expectedPackage._id))
663+
664+
if (piece.previousPieceInstanceId) {
665+
// Also try the previous PieceInstance, when this is an infinite continuation in case package-manager needs to catchup
666+
expectedPackageIds.unshift(
667+
getExpectedPackageId(piece.previousPieceInstanceId, expectedPackage._id)
668+
)
669+
}
659670
}
660671

661672
let warningMessage: ContentMessageLight | null = null

meteor/server/publications/pieceContentStatusUI/rundown/reactiveContentCache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ export const partInstanceFieldSpecifier = literal<
6464
part: 1, // This could be stricter, but this is unlikely to be changed once the PartInstance is created
6565
})
6666

67-
export type PieceInstanceFields = '_id' | 'rundownId' | 'partInstanceId' | 'piece'
67+
export type PieceInstanceFields = '_id' | 'rundownId' | 'partInstanceId' | 'piece' | 'infinite'
6868
export const pieceInstanceFieldSpecifier = literal<
6969
MongoFieldSpecifierOnesStrict<Pick<PieceInstance, PieceInstanceFields>>
7070
>({
7171
_id: 1,
7272
rundownId: 1,
7373
partInstanceId: 1,
7474
piece: 1, // This could be stricter, but this is unlikely to be changed once the PieceInstance is created
75+
infinite: 1, // This could be stricter, but this is temporary and should never change once set
7576
})
7677

7778
export type AdLibPieceFields =

meteor/server/publications/pieceContentStatusUI/rundown/regenerateItems.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,26 @@ export async function regenerateForPieceInstanceIds(
166166
const sourceLayer =
167167
pieceDoc.piece.sourceLayerId && sourceLayersForRundown?.sourceLayers?.[pieceDoc.piece.sourceLayerId]
168168

169+
let previousPieceInstanceId: PieceInstanceId | undefined
170+
if (pieceDoc.infinite) {
171+
// Note: this is a temporary solution, until single packages can be owned by multiple PieceInstances
172+
// This shouldn't need to be reactive upon this PieceInstance, as this is filling a brief gap until package-manager catches up.
173+
// That assumption could be wrong, but trying to track this dependency will be messy so would be nice to avoid.
174+
const previousPieceInstance = contentCache.PieceInstances.findOne({
175+
'infinite.infiniteInstanceId': pieceDoc.infinite.infiniteInstanceId,
176+
'infinite.infiniteInstanceIndex': pieceDoc.infinite.infiniteInstanceIndex - 1,
177+
})
178+
previousPieceInstanceId = previousPieceInstance?._id
179+
}
180+
169181
if (partInstance && segment && sourceLayer) {
170182
const [status, dependencies] = await checkPieceContentStatusAndDependencies(
171183
uiStudio,
172184
messageFactories.get(pieceDoc.rundownId),
173185
{
174186
...pieceDoc.piece,
175187
pieceInstanceId: pieceDoc._id,
188+
previousPieceInstanceId,
176189
},
177190
sourceLayer
178191
)

0 commit comments

Comments
 (0)