Skip to content

Commit 63a1d17

Browse files
committed
chore: log deleted documents, for troubleshooting
1 parent 2c113b5 commit 63a1d17

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/job-worker/src/ingest/model/implementation/DocumentChangeTracker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export class DocumentChangeTracker<TDoc extends { _id: ProtectedString<any> }> {
9494
}
9595
}
9696

97+
getDeletedIds(): TDoc['_id'][] {
98+
return Array.from(this.#deletedIds.values())
99+
}
100+
97101
/**
98102
* Generate the mongodb BulkWrite operations for the documents known to this tracker
99103
* @returns mongodb BulkWrite operations

packages/job-worker/src/ingest/model/implementation/SaveIngestModel.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { JobContext } from '../../../jobs'
1111
import { ExpectedPackagesStore } from './ExpectedPackagesStore'
1212
import { IngestSegmentModelImpl } from './IngestSegmentModelImpl'
1313
import { DocumentChangeTracker } from './DocumentChangeTracker'
14+
import { logger } from '../../../logging'
15+
import { ProtectedString } from '@sofie-automation/corelib/dist/protectedString'
1416

1517
export class SaveIngestModelHelper {
1618
#expectedPackages = new DocumentChangeTracker<ExpectedPackageDB>()
@@ -55,6 +57,23 @@ export class SaveIngestModelHelper {
5557
}
5658

5759
commit(context: JobContext): Array<Promise<unknown>> {
60+
// Log deleted ids:
61+
const deletedIds: { [key: string]: ProtectedString<any>[] } = {
62+
expectedPackages: this.#expectedPackages.getDeletedIds(),
63+
expectedPlayoutItems: this.#expectedPlayoutItems.getDeletedIds(),
64+
expectedMediaItems: this.#expectedMediaItems.getDeletedIds(),
65+
segments: this.#segments.getDeletedIds(),
66+
parts: this.#parts.getDeletedIds(),
67+
pieces: this.#pieces.getDeletedIds(),
68+
adLibPieces: this.#adLibPieces.getDeletedIds(),
69+
adLibActions: this.#adLibActions.getDeletedIds(),
70+
}
71+
for (const [key, ids] of Object.entries<ProtectedString<any>[]>(deletedIds)) {
72+
if (ids.length > 0) {
73+
logger.debug(`Deleted ${key}: ${JSON.stringify(ids)} `)
74+
}
75+
}
76+
5877
return [
5978
context.directCollections.ExpectedPackages.bulkWrite(this.#expectedPackages.generateWriteOps()),
6079
context.directCollections.ExpectedPlayoutItems.bulkWrite(this.#expectedPlayoutItems.generateWriteOps()),

0 commit comments

Comments
 (0)