Skip to content

Commit

Permalink
fix: cleanup expected packages when removing a segment
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed May 18, 2021
1 parent e608d98 commit 90be7be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 0 additions & 4 deletions meteor/lib/collections/ExpectedPlayoutItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export interface ExpectedPlayoutItemStudio extends ExpectedPlayoutItemBase {
}
/** @deprecated */
export type ExpectedPlayoutItem = ExpectedPlayoutItemStudio | ExpectedPlayoutItemRundown
/** @deprecated */
export function isExpectedPlayoutItemRundown(item: ExpectedPlayoutItem): item is ExpectedPlayoutItemRundown {
return item.baseline !== 'studio'
}

/** @deprecated */
export const ExpectedPlayoutItems: TransformedCollection<
Expand Down
20 changes: 13 additions & 7 deletions meteor/server/api/ingest/cleanup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isExpectedPlayoutItemRundown } from '../../../lib/collections/ExpectedPlayoutItems'
import { ExpectedPackageDB } from '../../../lib/collections/ExpectedPackages'
import { SegmentId } from '../../../lib/collections/Segments'
import { CacheForIngest } from './cache'

Expand All @@ -14,13 +14,19 @@ export function removeSegmentContents(cache: CacheForIngest, segmentIds: Set<Seg
if (removedPartIds.length > 0) {
// Clean up all the db items that belong to the removed Parts
const removedPartIds2 = new Set(removedPartIds)
cache.Pieces.remove((p) => removedPartIds2.has(p.startPartId))
cache.ExpectedPlayoutItems.remove(
(e) => isExpectedPlayoutItemRundown(e) && e.partId && removedPartIds2.has(e.partId)
)

const removedPieceIds = cache.Pieces.remove((p) => removedPartIds2.has(p.startPartId))
const removedAdlibIds = cache.AdLibPieces.remove((e) => e.partId && removedPartIds2.has(e.partId))
const removedActionIds = cache.AdLibActions.remove((e) => removedPartIds2.has(e.partId))
const allRemovedPieceIds: Set<NonNullable<ExpectedPackageDB['pieceId']>> = new Set([
...removedPieceIds,
...removedAdlibIds,
...removedActionIds,
])

cache.ExpectedPackages.remove((e) => e.pieceId && allRemovedPieceIds.has(e.pieceId))
cache.ExpectedPlayoutItems.remove((e) => 'partId' in e && e.partId && removedPartIds2.has(e.partId))
cache.ExpectedMediaItems.remove((e) => 'partId' in e && e.partId && removedPartIds2.has(e.partId))
cache.AdLibPieces.remove((e) => e.partId && removedPartIds2.has(e.partId))
cache.AdLibActions.remove((e) => removedPartIds2.has(e.partId))
}
}
}

0 comments on commit 90be7be

Please sign in to comment.