Skip to content

Commit f57c8a5

Browse files
committed
wip
1 parent 9db08fd commit f57c8a5

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

packages/job-worker/src/jobs/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ export { ProcessedShowStyleVariant, ProcessedShowStyleBase, ProcessedShowStyleCo
2525
export { JobStudio }
2626

2727
export interface QueueJobOptions {
28-
/** Optional: The job will be run with a low priority, allowing other operations to be run first */
28+
/**
29+
* The job should be run with a low priority, allowing other operations to be run first ]
30+
*/
2931
lowPriority?: boolean
3032

31-
/** Optional: Debounce execution, if the job is already queued, it will not be queued again */
32-
debounce?: boolean
33+
/**
34+
* Debounce execution, delaying execution until at least this wait time.
35+
* If the job is already queued, it will not be queued again
36+
*/
37+
debounce?: number
3338
}
3439

3540
/**

packages/job-worker/src/playout/model/implementation/SavePlayoutModel.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ export async function writeExpectedPackagesForPlayoutSources(
178178
)) as Pick<ExpectedPackageDB, '_id' | 'playoutSources'>[]
179179
const existingPackagesMap = normalizeArrayToMap(existingPackages, '_id')
180180

181-
// const targetPackages = new Map<ExpectedPackageId, ExpectedPackageEntry>()
182-
183181
const pieceInstancesToAddToPackages = new Map<ExpectedPackageId, PieceInstanceId[]>()
184182
const packagesToInsert = new Map<ExpectedPackageId, ExpectedPackageEntry>()
185183

@@ -203,12 +201,14 @@ export async function writeExpectedPackagesForPlayoutSources(
203201
pieceInstanceIds.push(pieceInstance.pieceInstance._id)
204202
pieceInstancesToAddToPackages.set(packageId, pieceInstanceIds)
205203
} else {
206-
// Record as needing a new package
204+
// Record as needing a new document
207205
packagesToInsert.set(packageId, {
208206
_id: packageId,
209207
package: expectedPackage,
210208
pieceInstanceIds: [pieceInstance.pieceInstance._id],
211209
})
210+
211+
// Future: If this came from a bucket, can we copy the packageInfos across to minimise latency until the status is ready?
212212
}
213213
}
214214
}
@@ -256,18 +256,15 @@ export async function writeExpectedPackagesForPlayoutSources(
256256
}
257257

258258
// We can't easily track any references which have been deleted, so we should schedule a cleanup job to deal with that for us
259-
await context.queueStudioJob(StudioJobs.CleanupOrphanedExpectedPackageReferences, {
260-
playlistId: playlistId,
261-
rundownId: rundownId,
262-
})
263-
264-
// TODO: Implement this function
265-
/**
266-
* Here we have access to all the PieceInstances for any 'current' partinstances (within the current segment?, and whatever is nexted)
267-
* So we can easily iterate through them all to build out the needed expected packages.
268-
* From there, we can make sure that they are referenced in the database.
269-
*
270-
* We can't track any references which have been deleted, so we probably want to dispatch a job to perform the cleanup on a debounce.
271-
* Timing isnt critical, as this will be stale and unreferenced data (other than it could cause package-manager to do pointless work)
272-
*/
259+
await context.queueStudioJob(
260+
StudioJobs.CleanupOrphanedExpectedPackageReferences,
261+
{
262+
playlistId: playlistId,
263+
rundownId: rundownId,
264+
},
265+
{
266+
lowPriority: true,
267+
debounce: 1000,
268+
}
269+
)
273270
}

0 commit comments

Comments
 (0)