Skip to content

Commit 8d84eef

Browse files
committed
wip
1 parent 2394f0c commit 8d84eef

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

packages/job-worker/src/ingest/bucket/bucketAdlibs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
import { omit } from '@sofie-automation/corelib/dist/lib'
2424
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
2525
import { BucketAdLibAction } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibAction'
26-
import { ExpectedPackageDBType } from '@sofie-automation/corelib/dist/dataModel/ExpectedPackages'
2726
import { MongoQuery } from '../../db'
2827

2928
export async function handleBucketRemoveAdlibPiece(

packages/job-worker/src/ingest/bucket/import.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ async function regenerateBucketItemFromIngestInfo(
161161
if (!showStyleCompound)
162162
throw new Error(`Unable to create a ShowStyleCompound for ${showStyleBase._id}, ${showStyleVariant._id} `)
163163

164-
const rawAdlib = await generateBucketAdlibForVariant(context, blueprint, showStyleCompound, ingestInfo.payload)
164+
const rawAdlib = await generateBucketAdlibForVariant(
165+
context,
166+
blueprint,
167+
showStyleCompound,
168+
bucketId,
169+
ingestInfo.payload
170+
)
165171

166172
if (rawAdlib) {
167173
const importVersions: RundownImportVersions = {
@@ -258,16 +264,22 @@ async function generateBucketAdlibForVariant(
258264
context: JobContext,
259265
blueprint: ReadonlyDeep<WrappedShowStyleBlueprint>,
260266
showStyleCompound: ReadonlyDeep<ProcessedShowStyleCompound>,
267+
bucketId: BucketId,
261268
// pieceId: BucketAdLibId | BucketAdLibActionId,
262269
payload: IngestAdlib
263270
): Promise<IBlueprintAdLibPiece | IBlueprintActionManifest | null> {
264271
if (!blueprint.blueprint.getAdlibItem) return null
265272

266273
const watchedPackages = await WatchedPackagesHelper.create(context, {
267-
// We don't know what the `pieceId` will be, but we do know the `externalId`
268-
pieceExternalId: payload.externalId,
269-
fromPieceType: {
270-
$in: [ExpectedPackageDBType.BUCKET_ADLIB, ExpectedPackageDBType.BUCKET_ADLIB_ACTION],
274+
bucketId,
275+
ingestSources: {
276+
$elemMatch: {
277+
fromPieceType: {
278+
$in: [ExpectedPackageDBType.BUCKET_ADLIB, ExpectedPackageDBType.BUCKET_ADLIB_ACTION],
279+
},
280+
// We don't know what the `pieceId` will be, but we do know the `externalId`
281+
pieceExternalId: payload.externalId,
282+
},
271283
},
272284
})
273285

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,6 @@ export async function executeAdlibActionAndSaveModel(
7676
throw UserError.create(UserErrorMessage.ActionsNotSupported)
7777
}
7878

79-
const watchedPackages = await WatchedPackagesHelper.create(context, {
80-
pieceId: data.actionDocId,
81-
fromPieceType: {
82-
$in: [
83-
ExpectedPackageDBType.ADLIB_ACTION,
84-
ExpectedPackageDBType.BASELINE_ADLIB_ACTION,
85-
ExpectedPackageDBType.BUCKET_ADLIB_ACTION,
86-
],
87-
},
88-
})
89-
9079
const [adLibAction, baselineAdLibAction, bucketAdLibAction] = await Promise.all([
9180
context.directCollections.AdLibActions.findOne(data.actionDocId as AdLibActionId, {
9281
projection: { _id: 1, privateData: 1 },
@@ -103,6 +92,24 @@ export async function executeAdlibActionAndSaveModel(
10392
])
10493
const adLibActionDoc = adLibAction ?? baselineAdLibAction ?? bucketAdLibAction
10594

95+
const watchedPackages = await WatchedPackagesHelper.create(context, {
96+
rundownId: adLibActionDoc && 'rundownId' in adLibActionDoc ? adLibActionDoc.rundownId : null,
97+
bucketId: adLibActionDoc && 'bucketId' in adLibActionDoc ? adLibActionDoc.bucketId : null,
98+
ingestSources: {
99+
$elemMatch: {
100+
fromPieceType: {
101+
$in: [
102+
ExpectedPackageDBType.ADLIB_ACTION,
103+
ExpectedPackageDBType.BASELINE_ADLIB_ACTION,
104+
ExpectedPackageDBType.BUCKET_ADLIB_ACTION,
105+
],
106+
},
107+
pieceId: data.actionDocId,
108+
},
109+
},
110+
pieceId: data.actionDocId,
111+
})
112+
106113
const actionParameters: ExecuteActionParameters = {
107114
actionId: data.actionId,
108115
userData: data.userData,

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export async function updateStudioTimeline(
8787
const studioBlueprint = context.studioBlueprint
8888
if (studioBlueprint) {
8989
const watchedPackages = await WatchedPackagesHelper.create(context, {
90-
fromPieceType: ExpectedPackageDBType.STUDIO_BASELINE_OBJECTS,
90+
rundownId: null,
91+
bucketId: null,
92+
ingestSources: {
93+
$elemMatch: {
94+
fromPieceType: ExpectedPackageDBType.STUDIO_BASELINE_OBJECTS,
95+
},
96+
},
9197
})
9298

9399
const blueprint = studioBlueprint.blueprint

0 commit comments

Comments
 (0)