Skip to content

Commit 0ffdcd7

Browse files
committed
hack: update piece content status pub
1 parent eeaa00d commit 0ffdcd7

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
} from '@sofie-automation/meteor-lib/dist/collections/ExpectedPackages'
4343
import { getActiveRoutes, getRoutedMappings } from '@sofie-automation/meteor-lib/dist/collections/Studios'
4444
import { ensureHasTrailingSlash, unprotectString } from '../../lib/tempLib'
45-
import { MediaObjects, PackageContainerPackageStatuses, PackageInfos } from '../../collections'
45+
import { ExpectedPackages, MediaObjects, PackageContainerPackageStatuses, PackageInfos } from '../../collections'
4646
import {
4747
mediaObjectFieldSpecifier,
4848
MediaObjectLight,
@@ -252,6 +252,27 @@ export async function checkPieceContentStatusAndDependencies(
252252
packageContainerId: string,
253253
expectedPackageId: ExpectedPackageId
254254
) => {
255+
if (piece.pieceInstanceId) {
256+
// nocommit - HACK. This is a temporary hack to help test that the ownership is tracked correctly.
257+
// This is intended to only match the package if it has the pieceinstance as an owner.
258+
// This should reveal issues with ownership being lost/forgotten even when the link for the underlying piece is still in place
259+
// This is not reactive, but that should be fine for this testing
260+
const hasDoc = await ExpectedPackages.findOneAsync(
261+
{
262+
_id: expectedPackageId,
263+
rundownId: packageOwnerId,
264+
bucketId: null,
265+
'playoutSources.pieceInstanceIds': piece.pieceInstanceId,
266+
},
267+
{
268+
projection: {
269+
_id: 1,
270+
},
271+
}
272+
)
273+
if (!hasDoc) return undefined
274+
}
275+
255276
const id = getPackageContainerPackageId(studio._id, packageContainerId, expectedPackageId)
256277
pieceDependencies.packageContainerPackageStatuses.push(id)
257278
return PackageContainerPackageStatuses.findOneAsync(
@@ -639,12 +660,6 @@ async function checkPieceContentExpectedPackageStatus(
639660

640661
// nocommit - strip out array
641662
const expectedPackageIds = [getExpectedPackageIdNew(packageOwnerId, expectedPackage)]
642-
// if (piece.pieceInstanceId) {
643-
// // If this is a PieceInstance, try looking up the PieceInstance first
644-
// expectedPackageIds.unshift(
645-
// getExpectedPackageIdForPieceInstance(piece.pieceInstanceId, expectedPackage._id)
646-
// )
647-
// }
648663

649664
let warningMessage: ContentMessageLight | null = null
650665
let matchedExpectedPackageId: ExpectedPackageId | null = null

0 commit comments

Comments
 (0)