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

Merge staging into develop #268

Merged
merged 4 commits into from
May 1, 2024
Merged
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
35 changes: 35 additions & 0 deletions packages/job-worker/src/ingest/rundownInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import {
UserRemoveRundownProps,
UserUnsyncRundownProps,
} from '@sofie-automation/corelib/dist/worker/ingest'
import { AdLibAction } from '@sofie-automation/corelib/dist/dataModel/AdlibAction'
import { AdLibPiece } from '@sofie-automation/corelib/dist/dataModel/AdLibPiece'

export async function handleRemovedRundown(context: JobContext, data: IngestRemoveRundownProps): Promise<void> {
return runIngestJob(
Expand Down Expand Up @@ -412,6 +414,9 @@ export async function handleUpdatedSegmentRanks(
},
})

updateAdLibActionRanks(externalId, rank, cache)
updateAdLibPieceRanks(externalId, rank, cache)

if (changed.length === 0) {
logger.warn(`Failed to update rank of segment "${externalId}" (${data.rundownExternalId})`)
} else {
Expand All @@ -432,6 +437,36 @@ export async function handleUpdatedSegmentRanks(
)
}

function updateAdLibActionRanks(segmentExternalId: string, newRank: number, cache: CacheForIngest): void {
const adLibActionsForSegment: AdLibAction[] = cache.AdLibActions.findFetch((adLibAction: AdLibAction) =>
adLibAction.externalId.startsWith(segmentExternalId)
)

for (const adLibAction of adLibActionsForSegment) {
const oldRankFraction: number = (adLibAction.display._rank ?? 1) % 1
cache.AdLibActions.update(adLibAction._id, {
$set: {
'display._rank': newRank + oldRankFraction,
},
})
}
}

function updateAdLibPieceRanks(segmentExternalId: string, newSegmentRank: number, cache: CacheForIngest): void {
const adLibPiecesForSegment: AdLibPiece[] = cache.AdLibPieces.findFetch((adLibPiece: AdLibPiece) =>
adLibPiece.externalId.startsWith(segmentExternalId)
)

for (const adLibPiece of adLibPiecesForSegment) {
const oldRankFraction: number = (adLibPiece._rank ?? 0) % 1
cache.AdLibPieces.update(adLibPiece._id, {
$set: {
_rank: newSegmentRank + oldRankFraction,
},
})
}
}

export async function handleRemoveOrphanedSegemnts(
context: JobContext,
data: RemoveOrphanedSegmentsProps
Expand Down
Loading