Skip to content

Commit

Permalink
fix: PieceInstance ExpectedPackages generated with incorrect id
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 27, 2024
1 parent 79ce01d commit 41761ef
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { PackageContainerOnPackage, Accessor, AccessorOnPackage } from '@sofie-automation/blueprints-integration'
import { getContentVersionHash } from '@sofie-automation/corelib/dist/dataModel/ExpectedPackages'
import { PeripheralDeviceId, ExpectedPackageId, PieceInstanceId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { getContentVersionHash, getExpectedPackageId } from '@sofie-automation/corelib/dist/dataModel/ExpectedPackages'
import {
PeripheralDeviceId,
ExpectedPackageId,
PieceInstanceId,
PieceId,
} from '@sofie-automation/corelib/dist/dataModel/Ids'

Check warning on line 8 in meteor/server/publications/packageManager/expectedPackages/generate.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/packageManager/expectedPackages/generate.ts#L2-L8

Added lines #L2 - L8 were not covered by tests
import { protectString, unprotectString } from '@sofie-automation/corelib/dist/protectedString'
import {
PackageManagerExpectedPackage,
Expand Down Expand Up @@ -115,7 +120,10 @@ export async function updateCollectionForPieceInstanceIds(
if (!pieceInstanceDoc.piece?.expectedPackages) continue

pieceInstanceDoc.piece.expectedPackages.forEach((expectedPackage, i) => {
const sanitisedPackageId = expectedPackage._id || '__unnamed' + i
const sanitisedPackageId = getExpectedPackageId(
protectString<PieceId>(unprotectString(pieceInstanceId)),
expectedPackage._id || '__unnamed' + i
)

Check warning on line 126 in meteor/server/publications/packageManager/expectedPackages/generate.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/packageManager/expectedPackages/generate.ts#L123-L126

Added lines #L123 - L126 were not covered by tests

// Map the expectedPackages onto their specified layer:
const allDeviceIds = new Set<PeripheralDeviceId>()
Expand All @@ -134,7 +142,7 @@ export async function updateCollectionForPieceInstanceIds(
studio,
{
...expectedPackage,
_id: `${pieceInstanceId}_${sanitisedPackageId}`,
_id: unprotectString(sanitisedPackageId),

Check warning on line 145 in meteor/server/publications/packageManager/expectedPackages/generate.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/packageManager/expectedPackages/generate.ts#L145

Added line #L145 was not covered by tests
rundownId: pieceInstanceDoc.rundownId,
contentVersionHash: getContentVersionHash(expectedPackage),
},
Expand Down

0 comments on commit 41761ef

Please sign in to comment.