Skip to content

Commit 8027660

Browse files
committed
wip: id collisions
1 parent 7404d18 commit 8027660

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ import type { ExpectedPackageIngestSource } from '@sofie-automation/corelib/dist
1515
export class WatchedPackagesHelper {
1616
private readonly packages = new Map<
1717
ExpectedPackageId,
18-
ReadonlyDeep<IngestExpectedPackage<ExpectedPackageIngestSource>>
18+
ReadonlyDeep<IngestExpectedPackage<ExpectedPackageIngestSource>>[]
1919
>()
2020

2121
private constructor(
2222
packages: ReadonlyDeep<IngestExpectedPackage<ExpectedPackageIngestSource>[]>,
2323
private readonly packageInfos: ReadonlyDeep<PackageInfoDB[]>
2424
) {
2525
for (const pkg of packages) {
26-
this.packages.set(pkg.packageId, pkg)
26+
const arr = this.packages.get(pkg.packageId) || []
27+
arr.push(pkg)
28+
this.packages.set(pkg.packageId, arr)
2729
}
2830
}
2931

@@ -152,8 +154,10 @@ export class WatchedPackagesHelper {
152154
func: (pkg: ReadonlyDeep<IngestExpectedPackage<ExpectedPackageIngestSource>>) => boolean
153155
): WatchedPackagesHelper {
154156
const watchedPackages: ReadonlyDeep<IngestExpectedPackage<ExpectedPackageIngestSource>>[] = []
155-
for (const pkg of this.packages.values()) {
156-
if (func(pkg)) watchedPackages.push(pkg)
157+
for (const packages of this.packages.values()) {
158+
for (const pkg of packages) {
159+
if (func(pkg)) watchedPackages.push(pkg)
160+
}
157161
}
158162

159163
const newPackageIds = new Set(watchedPackages.map((p) => p.packageId))
@@ -167,10 +171,13 @@ export class WatchedPackagesHelper {
167171
}
168172

169173
getPackageInfo(packageId: string): Readonly<Array<PackageInfo.Any>> {
170-
for (const pkg of this.packages.values()) {
171-
if (pkg.package._id === packageId) {
172-
const info = this.packageInfos.filter((p) => p.packageId === pkg.packageId)
173-
return unprotectObjectArray(info)
174+
// nocommit - can this/should this do more scoping by source?
175+
for (const packages of this.packages.values()) {
176+
for (const pkg of packages) {
177+
if (pkg.package._id === packageId) {
178+
const info = this.packageInfos.filter((p) => p.packageId === pkg.packageId)
179+
return unprotectObjectArray(info)
180+
}
174181
}
175182
}
176183

0 commit comments

Comments
 (0)