From 7f9fe5b387ac8693cf679f309fe27bf5d82edc7c Mon Sep 17 00:00:00 2001 From: Rasmus Lindved Date: Tue, 14 May 2024 09:04:49 +0200 Subject: [PATCH 1/2] SOF-1979 Add 'invalidity' field to Segment --- src/tv2-common/getSegment.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/tv2-common/getSegment.ts b/src/tv2-common/getSegment.ts index a5cbdd94..9590ab3f 100644 --- a/src/tv2-common/getSegment.ts +++ b/src/tv2-common/getSegment.ts @@ -84,6 +84,14 @@ export interface GetSegmentShowstyleOptions BlueprintResultPart | Promise } +interface Segment extends IBlueprintSegment { + invalidity?: SegmentInvalidity +} + +interface SegmentInvalidity { + reason: string +} + interface SegmentMetadata { miniShelfVideoClipFile?: string } @@ -97,7 +105,7 @@ export async function getSegmentBase const segmentPayload = ingestSegment.payload as INewsPayload | undefined const iNewsStory = segmentPayload?.iNewsStory - const segment: IBlueprintSegment = { + const segment: Segment = { name: ingestSegment.name || '', metaData: {}, showShelf: false, @@ -385,8 +393,23 @@ export async function getSegmentBase } }) + segment.invalidity = getSegmentInvalidity(segment, blueprintParts) + return { segment, parts: blueprintParts } } + +function getSegmentInvalidity( + segment: Segment, + parts: BlueprintResultPart[] +): SegmentInvalidity | undefined { + const doesSegmentHaveMiniShelf: boolean = !!segment.metaData?.miniShelfVideoClipFile + if (doesSegmentHaveMiniShelf && parts.length > 0) { + return { + reason: 'MiniShelf Segments are not allowed to also have Parts.' + } + } + return undefined +} From edd41b82b2619797610063df90199b2b8b76681d Mon Sep 17 00:00:00 2001 From: Rasmus Lindved Date: Tue, 14 May 2024 11:49:17 +0200 Subject: [PATCH 2/2] SOF-1979 Parts that have zero Pieces does not count for making a Segment invalid --- src/tv2-common/getSegment.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tv2-common/getSegment.ts b/src/tv2-common/getSegment.ts index 9590ab3f..a9dbc78b 100644 --- a/src/tv2-common/getSegment.ts +++ b/src/tv2-common/getSegment.ts @@ -406,7 +406,8 @@ function getSegmentInvalidity( parts: BlueprintResultPart[] ): SegmentInvalidity | undefined { const doesSegmentHaveMiniShelf: boolean = !!segment.metaData?.miniShelfVideoClipFile - if (doesSegmentHaveMiniShelf && parts.length > 0) { + const doesSegmentHaveValidParts: boolean = parts.length > 0 && parts.some((part) => part.pieces.length > 0) + if (doesSegmentHaveMiniShelf && doesSegmentHaveValidParts) { return { reason: 'MiniShelf Segments are not allowed to also have Parts.' }