Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOF-1912 Update AdLib Rank with SegmentRank #239

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/tv2-common/actions/executeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,8 @@ async function executeActionSelectFull<
partId: externalId,
parsedCue: cue,
segmentExternalId: userData.segmentExternalId,
adlib: { rank: 0 }
adlib: { rank: 0 },
rank: 0
})

const fullPiece = generator.createPiece()
Expand Down
66 changes: 55 additions & 11 deletions src/tv2-common/evaluateCues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
GraphicIsPilot
} from './inewsConversion'

const PART_RANK_FRACTION_FACTOR: number = 1000

export interface Adlib {
rank: number
}
Expand All @@ -59,6 +61,7 @@ export interface EvaluateCuesShowstyleOptions {
partId: string,
parsedCue: CueDefinitionGraphic<GraphicInternalOrPilot>,
partDefinition: PartDefinition,
rank: number,
adlib?: Adlib
) => EvaluateCueResult
EvaluateCueBackgroundLoop?: (
Expand Down Expand Up @@ -192,13 +195,13 @@ export async function EvaluateCuesBase(
partDefinition: PartDefinition,
options: EvaluateCuesOptions
) {
let adLibRank = 0
let adLibRank = 1
const result = new EvaluateCueResult()

for (const cue of cues) {
if (cue && !SkipCue(cue, options.selectedCueTypes, options.excludeAdlibs, options.adlibsOnly)) {
const shouldAdlib = !!(options.adlib || cue.adlib)
const adlib = shouldAdlib ? { rank: adLibRank } : undefined
const adlib = shouldAdlib ? { rank: getRankForPartDefinition(adLibRank, partDefinition) } : undefined

switch (cue.type) {
case CueType.Graphic:
Expand All @@ -213,7 +216,14 @@ export async function EvaluateCuesBase(
break
}
result.push(
showStyleOptions.EvaluateCueGraphic(context, partDefinition.externalId, cue, partDefinition, adlib)
showStyleOptions.EvaluateCueGraphic(
context,
partDefinition.externalId,
cue,
partDefinition,
getRankForPartDefinition(adLibRank, partDefinition),
adlib
)
)
}
break
Expand All @@ -227,17 +237,33 @@ export async function EvaluateCuesBase(
cue,
partDefinition,
shouldAdlib,
adLibRank
getRankForPartDefinition(adLibRank, partDefinition)
)
)
}
break
case CueType.DVE:
if (showStyleOptions.EvaluateCueDVE) {
showStyleOptions.EvaluateCueDVE(context, pieces, actions, partDefinition, cue, shouldAdlib, adLibRank)
showStyleOptions.EvaluateCueDVE(
context,
pieces,
actions,
partDefinition,
cue,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
)
// Always make an adlib for DVEs
if (!shouldAdlib) {
showStyleOptions.EvaluateCueDVE(context, pieces, actions, partDefinition, cue, true, adLibRank)
showStyleOptions.EvaluateCueDVE(
context,
pieces,
actions,
partDefinition,
cue,
true,
getRankForPartDefinition(adLibRank, partDefinition)
)
}
}
break
Expand All @@ -249,7 +275,7 @@ export async function EvaluateCuesBase(
mediaSubscriptions,
cue,
partDefinition,
adLibRank
getRankForPartDefinition(adLibRank, partDefinition)
)
}
break
Expand All @@ -262,7 +288,15 @@ export async function EvaluateCuesBase(
break
case CueType.Jingle:
if (showStyleOptions.EvaluateCueJingle) {
showStyleOptions.EvaluateCueJingle(context, pieces, actions, cue, partDefinition, shouldAdlib, adLibRank)
showStyleOptions.EvaluateCueJingle(
context,
pieces,
actions,
cue,
partDefinition,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
)
}
break
case CueType.LYD:
Expand All @@ -275,14 +309,20 @@ export async function EvaluateCuesBase(
cue,
partDefinition,
shouldAdlib,
adLibRank
getRankForPartDefinition(adLibRank, partDefinition)
)
}
break
case CueType.GraphicDesign:
if (showStyleOptions.EvaluateCueGraphicDesign) {
result.push(
showStyleOptions.EvaluateCueGraphicDesign(context, partDefinition.externalId, cue, shouldAdlib, adLibRank)
showStyleOptions.EvaluateCueGraphicDesign(
context,
partDefinition.externalId,
cue,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
)
)
}
break
Expand Down Expand Up @@ -312,7 +352,7 @@ export async function EvaluateCuesBase(
partDefinition.externalId,
cue,
shouldAdlib,
adLibRank
getRankForPartDefinition(adLibRank, partDefinition)
)
)
}
Expand Down Expand Up @@ -401,6 +441,10 @@ export async function EvaluateCuesBase(
})
}

function getRankForPartDefinition(rank: number, partDefinition: PartDefinition): number {
return partDefinition.segmentRank + rank / PART_RANK_FRACTION_FACTOR
}

export function SkipCue(
cue: CueDefinition,
selectedCueTypes?: CueType[] | undefined,
Expand Down
2 changes: 2 additions & 0 deletions src/tv2-common/get-next-part-cue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const SOURCE_DEFINITION_KAM_2: SourceDefinitionKam = {
const partDefinitionTest1: PartDefinitionKam = {
type: PartType.Kam,
externalId: 'test-part',
segmentRank: 1,
rawType: 'KAM 1',
sourceDefinition: SOURCE_DEFINITION_KAM_1,
fields: {},
Expand Down Expand Up @@ -169,6 +170,7 @@ const partDefinitionTest1: PartDefinitionKam = {
const partDefinitionTest2: PartDefinitionKam = {
type: PartType.Kam,
externalId: 'test-part',
segmentRank: 1,
rawType: 'KAM 1',
sourceDefinition: SOURCE_DEFINITION_KAM_1,
fields: {},
Expand Down
1 change: 1 addition & 0 deletions src/tv2-common/getSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export async function getSegmentBase<ShowStyleConfig extends TV2ShowStyleConfig>
config,
ingestSegment.externalId,
ingestSegment.name,
ingestSegment.rank,
iNewsStory.body,
iNewsStory.cues,
iNewsStory.fields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function makeGenerator(cue: CueDefinitionGraphic<GraphicPilot>) {
context,
partId: 'part01',
parsedCue: cue,
segmentExternalId: ''
segmentExternalId: '',
rank: 0
})
return generator
}
Expand Down
2 changes: 2 additions & 0 deletions src/tv2-common/helpers/graphics/internal/InternalGraphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export abstract class InternalGraphic extends Graphic {
this.outputLayerId = IsTargetingWall(this.engine) ? SharedOutputLayer.SEC : SharedOutputLayer.OVERLAY
this.partId = graphicProps.partId
this.content = this.getContent()
this.rank = graphicProps.rank
}

public createCommentatorAdlib(): IBlueprintAdLibPiece<PieceMetaData> {
Expand Down Expand Up @@ -145,4 +146,5 @@ export interface InternalGraphicProps {
parsedCue: CueDefinitionGraphic<GraphicInternal>
partId?: string
partDefinition?: PartDefinition
rank: number
}
8 changes: 7 additions & 1 deletion src/tv2-common/helpers/graphics/internal/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ export function CreateInternalGraphic(
adlib?: Adlib
): EvaluateCueResult {
const result = new EvaluateCueResult()
const internalGraphic = InternalGraphic.createInternalGraphicGenerator({ context, parsedCue, partId, partDefinition })
const internalGraphic = InternalGraphic.createInternalGraphicGenerator({
context,
parsedCue,
partId,
partDefinition,
rank: adlib?.rank ?? 0
})

if (!internalGraphic.templateName || !internalGraphic.templateName.length) {
context.core.notifyUserWarning(`No valid template found for ${parsedCue.graphic.template}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface PilotGraphicProps {
partId: string
parsedCue: CueDefinitionGraphic<GraphicPilot>
adlib?: Adlib
rank: number
segmentExternalId: string
}

Expand All @@ -61,6 +62,7 @@ export abstract class PilotGraphicGenerator extends Graphic {
protected readonly partId: string
protected readonly cue: CueDefinitionGraphic<GraphicPilot>
protected readonly adlib?: Adlib
protected readonly rank: number
protected readonly segmentExternalId: string

protected constructor(graphicProps: PilotGraphicProps) {
Expand All @@ -71,6 +73,7 @@ export abstract class PilotGraphicGenerator extends Graphic {
this.cue = graphicProps.parsedCue
this.partId = graphicProps.partId
this.adlib = graphicProps.adlib
this.rank = graphicProps.rank
this.segmentExternalId = graphicProps.segmentExternalId
}

Expand All @@ -88,12 +91,12 @@ export abstract class PilotGraphicGenerator extends Graphic {
segmentExternalId: this.segmentExternalId
}
return {
externalId: generateExternalId(this.core, userData),
externalId: `${this.segmentExternalId}_${generateExternalId(this.core, userData)}`,
actionId: AdlibActionType.SELECT_FULL_GRAFIK,
userData,
userDataManifest: {},
display: {
_rank: (this.adlib && this.adlib.rank) || 0,
_rank: (this.adlib && this.adlib.rank) || this.rank,
label: t(this.getTemplateName()),
sourceLayerId: SharedSourceLayer.PgmPilot,
outputLayerId: SharedOutputLayer.PGM,
Expand Down Expand Up @@ -142,7 +145,7 @@ export abstract class PilotGraphicGenerator extends Graphic {
pilotPiece.tags = [...(pilotPiece.tags ?? []), AdlibTags.ADLIB_FLOW_PRODUCER, AdlibTags.ADLIB_KOMMENTATOR]
return {
...pilotPiece,
_rank: rank ?? 0
_rank: rank ?? this.rank
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tv2-common/helpers/graphics/pilot/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function CreatePilotGraphic(pilotGraphicProps: PilotGraphicProps): Evalua
const generator = PilotGraphicGenerator.createPilotGraphicGenerator(pilotGraphicProps)

if (IsTargetingOVL(parsedCue.target) && adlib) {
result.adlibPieces.push(generator.createAdlibPiece())
result.adlibPieces.push(generator.createAdlibPiece(adlib.rank))
} else {
result.pieces.push(generator.createPiece())
}
Expand Down
Loading
Loading