Skip to content

Commit 65434c9

Browse files
committed
chore: tidy
1 parent db11004 commit 65434c9

File tree

6 files changed

+30
-48
lines changed

6 files changed

+30
-48
lines changed

packages/job-worker/src/blueprints/context/watchedPackages.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PackageInfoDB } from '@sofie-automation/corelib/dist/dataModel/PackageInfos'
22
import { JobContext } from '../../jobs'
3-
import { ExpectedPackageId } from '@sofie-automation/corelib/dist/dataModel/Ids'
3+
import { BucketId, ExpectedPackageId, RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids'
44
import { Filter as FilterQuery } from 'mongodb'
55
import { PackageInfo } from '@sofie-automation/blueprints-integration'
66
import { unprotectObjectArray } from '@sofie-automation/corelib/dist/protectedString'
@@ -10,7 +10,7 @@ import {
1010
stripExpectedPackageDBToIngestExpectedPackage,
1111
type IngestExpectedPackage,
1212
} from '../../ingest/model/IngestExpectedPackage'
13-
import { ExpectedPackageDB } from '@sofie-automation/corelib/dist/dataModel/ExpectedPackages'
13+
import type { ExpectedPackageIngestSource } from '@sofie-automation/corelib/dist/dataModel/ExpectedPackages'
1414

1515
/**
1616
* This is a helper class to simplify exposing packageInfo to various places in the blueprints
@@ -41,12 +41,18 @@ export class WatchedPackagesHelper {
4141
*/
4242
static async create(
4343
context: JobContext,
44-
filter: FilterQuery<Omit<ExpectedPackageDB, 'studioId'>>
44+
rundownId: RundownId | null,
45+
bucketId: BucketId | null,
46+
filterIngestSources: FilterQuery<ExpectedPackageIngestSource>
4547
): Promise<WatchedPackagesHelper> {
4648
// Load all the packages and the infos that are watched
4749
const watchedPackages = await context.directCollections.ExpectedPackages.findFetch({
48-
...filter,
4950
studioId: context.studioId,
51+
rundownId: rundownId,
52+
bucketId: bucketId,
53+
ingestSources: {
54+
$elemMatch: filterIngestSources,
55+
},
5056
})
5157
const watchedPackageInfos = await context.directCollections.PackageInfos.findFetch({
5258
studioId: context.studioId,

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,12 @@ async function generateBucketAdlibForVariant(
270270
): Promise<IBlueprintAdLibPiece | IBlueprintActionManifest | null> {
271271
if (!blueprint.blueprint.getAdlibItem) return null
272272

273-
const watchedPackages = await WatchedPackagesHelper.create(context, {
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-
},
273+
const watchedPackages = await WatchedPackagesHelper.create(context, null, bucketId, {
274+
fromPieceType: {
275+
$in: [ExpectedPackageDBType.BUCKET_ADLIB, ExpectedPackageDBType.BUCKET_ADLIB_ACTION],
283276
},
277+
// We don't know what the `pieceId` will be, but we do know the `externalId`
278+
pieceExternalId: payload.externalId,
284279
})
285280

286281
const contextForVariant = new ShowStyleUserContext(

packages/job-worker/src/ingest/model/IngestModel.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ export interface IngestModel extends IngestModelReadonly, BaseModel, INotificati
204204
*/
205205
setExpectedMediaItemsForRundownBaseline(expectedMediaItems: ExpectedMediaItemRundown[]): void
206206

207-
// /**
208-
// * Set the ExpectedPackages for the baseline of this Rundown
209-
// * @param expectedPackages The new ExpectedPackages
210-
// */
211-
// setExpectedPackagesForRundownBaseline(expectedPackages: ExpectedPackageForIngestModelBaseline[]): void
212-
213207
/**
214208
* Set the data for this Rundown.
215209
* This will either update or create the Rundown

packages/job-worker/src/ingest/model/implementation/IngestModelImpl.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,6 @@ export class IngestModelImpl implements IngestModel, IngestDatabasePersistedMode
404404
setExpectedMediaItemsForRundownBaseline(expectedMediaItems: ExpectedMediaItemRundown[]): void {
405405
this.#rundownBaselineExpectedPackagesStore.setExpectedMediaItems(expectedMediaItems)
406406
}
407-
// setExpectedPackagesForRundownBaseline(expectedPackages: ExpectedPackageForIngestModelBaseline[]): void {
408-
// // Future: should these be here, or held as part of each adlib?
409-
// this.#rundownBaselineExpectedPackagesStore.setExpectedPackages(expectedPackages)
410-
// }
411407

412408
setRundownData(
413409
rundownData: IBlueprintRundown,

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

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,20 @@ export async function executeAdlibActionAndSaveModel(
9292
])
9393
const adLibActionDoc = adLibAction ?? baselineAdLibAction ?? bucketAdLibAction
9494

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,
95+
let watchedPackages = WatchedPackagesHelper.empty(context)
96+
if (adLibActionDoc && 'rundownId' in adLibActionDoc) {
97+
watchedPackages = await WatchedPackagesHelper.create(context, adLibActionDoc.rundownId, null, {
98+
fromPieceType: {
99+
$in: [ExpectedPackageDBType.ADLIB_ACTION, ExpectedPackageDBType.BASELINE_ADLIB_ACTION],
108100
},
109-
},
110-
pieceId: data.actionDocId,
111-
})
101+
pieceId: data.actionDocId,
102+
})
103+
} else if (adLibActionDoc && 'bucketId' in adLibActionDoc) {
104+
watchedPackages = await WatchedPackagesHelper.create(context, null, adLibActionDoc.bucketId, {
105+
fromPieceType: ExpectedPackageDBType.BUCKET_ADLIB_ACTION,
106+
pieceId: data.actionDocId,
107+
})
108+
}
112109

113110
const actionParameters: ExecuteActionParameters = {
114111
actionId: data.actionId,

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,8 @@ export async function updateStudioTimeline(
8686

8787
const studioBlueprint = context.studioBlueprint
8888
if (studioBlueprint) {
89-
const watchedPackages = await WatchedPackagesHelper.create(context, {
90-
rundownId: null,
91-
bucketId: null,
92-
ingestSources: {
93-
$elemMatch: {
94-
fromPieceType: ExpectedPackageDBType.STUDIO_BASELINE_OBJECTS,
95-
},
96-
},
89+
const watchedPackages = await WatchedPackagesHelper.create(context, null, null, {
90+
fromPieceType: ExpectedPackageDBType.STUDIO_BASELINE_OBJECTS,
9791
})
9892

9993
const blueprint = studioBlueprint.blueprint

0 commit comments

Comments
 (0)