Skip to content

Commit 8c16ce8

Browse files
jstarplnytamin
andcommitted
feat: add more logging
Co-authored-by: Johan Nyman <[email protected]>
1 parent b20367b commit 8c16ce8

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

packages/job-worker/src/ingest/commit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export async function CommitIngestOperation(
179179
await updateSegmentIdsForAdlibbedPartInstances(context, ingestModel, beforePartMap)
180180

181181
if (data.renamedSegments && data.renamedSegments.size > 0) {
182-
logger.debug(`Renamed segments: ${JSON.stringify(Array.from(data.renamedSegments.entries()))}`)
182+
logger.verbose(`Renamed segments: ${JSON.stringify(Array.from(data.renamedSegments.entries()))}`)
183183
}
184184
// ensure instances have matching segmentIds with the parts
185185
await updatePartInstancesSegmentIds(context, ingestModel, data.renamedSegments, beforePartMap)
@@ -820,6 +820,7 @@ async function removeSegments(
820820
})
821821
}
822822
for (const segmentId of purgeSegmentIds) {
823+
logger.debug(`IngestModel: Removing segment "${segmentId}"`)
823824
ingestModel.removeSegment(segmentId)
824825
}
825826
}

packages/job-worker/src/ingest/mosDevice/diff.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { IngestSegment } from '@sofie-automation/blueprints-integration'
1111
import { SegmentOrphanedReason } from '@sofie-automation/corelib/dist/dataModel/Segment'
1212
import { CommitIngestData } from '../lock'
1313
import { IngestSegmentModel } from '../model/IngestSegmentModel'
14+
import { logger } from '../../logging'
1415

1516
/**
1617
* Update the Ids of Segments based on new Ingest data
@@ -158,9 +159,11 @@ function applyExternalIdDiff(
158159
}
159160

160161
// Remove the old Segment and it's contents, the new one will be generated shortly
162+
logger.debug(`applyExternalIdDiff: Marking Segment for removing "${oldSegmentId}"`)
161163
ingestModel.removeSegment(oldSegmentId)
162164
} else {
163165
// Perform the rename
166+
logger.debug(`applyExternalIdDiff: Marking Segment for renaming "${oldSegmentId}" -> "${newSegmentId}"`)
164167
ingestModel.changeSegmentId(oldSegmentId, newSegmentId)
165168
}
166169
}

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,29 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
751751
if (this.rundownsImpl.find((rd) => rd.AdlibTestingSegmentHasChanged))
752752
logOrThrowError(new Error(`Failed no changes in model assertion, an AdlibTesting Segment has been changed`))
753753

754-
if (
755-
Array.from(this.allPartInstances.values()).find(
756-
(part) => !part || part.partInstanceHasChanges || part.changedPieceInstanceIds().length > 0
757-
)
754+
const changedPartInstances = Array.from(this.allPartInstances.entries()).filter(
755+
([_, partInstance]) =>
756+
partInstance !== null && // null values mean a PartInstance was removed, which doesn't need to be tracked
757+
(partInstance.partInstanceHasChanges || partInstance.changedPieceInstanceIds().length > 0)
758758
)
759-
logOrThrowError(new Error(`Failed no changes in model assertion, a PartInstance has been changed`))
759+
760+
if (changedPartInstances.length > 0) {
761+
logOrThrowError(
762+
new Error(
763+
`Failed no changes in model assertion, PartInstances has been changed: ${JSON.stringify(
764+
changedPartInstances.map(
765+
([id, pi]) =>
766+
`${id}: ` +
767+
(!pi
768+
? 'null'
769+
: `partInstanceHasChanges: ${
770+
pi.partInstanceHasChanges
771+
}, changedPieceInstanceIds: ${JSON.stringify(pi.changedPieceInstanceIds())}`)
772+
)
773+
)}`
774+
)
775+
)
776+
}
760777

761778
if (span) span.end()
762779
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,11 @@ async function cleanupOrphanedItems(context: JobContext, playoutModel: PlayoutMo
279279

280280
const selectedPartInstancesSegmentIds = new Set<SegmentId>()
281281

282+
const previousPartInstance = playoutModel.previousPartInstance?.partInstance
282283
const currentPartInstance = playoutModel.currentPartInstance?.partInstance
283284
const nextPartInstance = playoutModel.nextPartInstance?.partInstance
284285

286+
if (previousPartInstance) selectedPartInstancesSegmentIds.add(previousPartInstance.segmentId)
285287
if (currentPartInstance) selectedPartInstancesSegmentIds.add(currentPartInstance.segmentId)
286288
if (nextPartInstance) selectedPartInstancesSegmentIds.add(nextPartInstance.segmentId)
287289

@@ -291,7 +293,7 @@ async function cleanupOrphanedItems(context: JobContext, playoutModel: PlayoutMo
291293

292294
const alterSegmentsFromRundowns = new Map<RundownId, { deleted: SegmentId[]; hidden: SegmentId[] }>()
293295
for (const segment of segments) {
294-
// If the segment is orphaned and not the segment for the next or current partinstance
296+
// If the segment is orphaned and not the segment for the previous, current or next partInstance
295297
if (!selectedPartInstancesSegmentIds.has(segment.segment._id)) {
296298
let rundownSegments = alterSegmentsFromRundowns.get(segment.segment.rundownId)
297299
if (!rundownSegments) {

0 commit comments

Comments
 (0)