Skip to content

Commit ad6aa35

Browse files
committed
wip: cleanup
1 parent 7184afe commit ad6aa35

File tree

4 files changed

+0
-198
lines changed

4 files changed

+0
-198
lines changed

meteor/server/publications/packageManager/expectedPackages/contentCache.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,6 @@ import { ReactiveCacheCollection } from '../../lib/ReactiveCacheCollection'
22
import { literal } from '@sofie-automation/corelib/dist/lib'
33
import { MongoFieldSpecifierOnesStrict } from '@sofie-automation/corelib/dist/mongo'
44
import { ExpectedPackageDB } from '@sofie-automation/corelib/dist/dataModel/ExpectedPackages'
5-
// import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
6-
// import { PieceInstance, PieceInstancePiece } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
7-
8-
// export type RundownPlaylistCompact = Pick<
9-
// DBRundownPlaylist,
10-
// '_id' | 'activationId' | 'currentPartInfo' | 'nextPartInfo'
11-
// >
12-
// export const rundownPlaylistFieldSpecifier = literal<MongoFieldSpecifierOnesStrict<RundownPlaylistCompact>>({
13-
// _id: 1,
14-
// activationId: 1,
15-
// currentPartInfo: 1, // So that it invalidates when the current changes
16-
// nextPartInfo: 1, // So that it invalidates when the next changes
17-
// })
18-
19-
// export type PieceInstanceCompact = Pick<PieceInstance, '_id' | 'rundownId'> & {
20-
// piece: Pick<PieceInstancePiece, 'expectedPackages'>
21-
// }
22-
23-
// export const pieceInstanceFieldsSpecifier = literal<MongoFieldSpecifierOnesStrict<PieceInstanceCompact>>({
24-
// _id: 1,
25-
// rundownId: 1,
26-
// piece: {
27-
// expectedPackages: 1,
28-
// },
29-
// })
305

316
export type ExpectedPackageDBCompact = Pick<ExpectedPackageDB, '_id' | 'package'>
327

@@ -37,15 +12,11 @@ export const expectedPackageDBFieldsSpecifier = literal<MongoFieldSpecifierOnesS
3712

3813
export interface ExpectedPackagesContentCache {
3914
ExpectedPackages: ReactiveCacheCollection<ExpectedPackageDBCompact>
40-
// RundownPlaylists: ReactiveCacheCollection<RundownPlaylistCompact>
41-
// PieceInstances: ReactiveCacheCollection<PieceInstanceCompact>
4215
}
4316

4417
export function createReactiveContentCache(): ExpectedPackagesContentCache {
4518
const cache: ExpectedPackagesContentCache = {
4619
ExpectedPackages: new ReactiveCacheCollection<ExpectedPackageDBCompact>('expectedPackages'),
47-
// RundownPlaylists: new ReactiveCacheCollection<RundownPlaylistCompact>('rundownPlaylists'),
48-
// PieceInstances: new ReactiveCacheCollection<PieceInstanceCompact>('pieceInstances'),
4920
}
5021

5122
return cache

meteor/server/publications/packageManager/expectedPackages/contentObserver.ts

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@ import { ExpectedPackagesContentCache, expectedPackageDBFieldsSpecifier } from '
55
import { ExpectedPackages } from '../../../collections'
66
import { waitForAllObserversReady } from '../../lib/lib'
77

8-
// const REACTIVITY_DEBOUNCE = 20
9-
108
export class ExpectedPackagesContentObserver implements Meteor.LiveQueryHandle {
119
#observers: Meteor.LiveQueryHandle[] = []
1210
#cache: ExpectedPackagesContentCache
1311

14-
// #partInstanceIds: PartInstanceId[] = []
15-
// // #partInstanceIdObserver!: ReactiveMongoObserverGroupHandle
16-
17-
// #disposed = false
18-
1912
private constructor(cache: ExpectedPackagesContentCache) {
2013
this.#cache = cache
2114
}
@@ -28,27 +21,7 @@ export class ExpectedPackagesContentObserver implements Meteor.LiveQueryHandle {
2821

2922
const observer = new ExpectedPackagesContentObserver(cache)
3023

31-
// // Run the ShowStyleBase query in a ReactiveMongoObserverGroup, so that it can be restarted whenever
32-
// observer.#partInstanceIdObserver = await ReactiveMongoObserverGroup(async () => {
33-
// // Clear already cached data
34-
// cache.PieceInstances.remove({})
35-
36-
// return [
37-
// PieceInstances.observeChanges(
38-
// {
39-
// // We can use the `this.#partInstanceIds` here, as this is restarted every time that property changes
40-
// partInstanceId: { $in: observer.#partInstanceIds },
41-
// },
42-
// cache.PieceInstances.link(),
43-
// {
44-
// projection: pieceInstanceFieldsSpecifier,
45-
// }
46-
// ),
47-
// ]
48-
// })
49-
5024
// Subscribe to the database, and pipe any updates into the ReactiveCacheCollections
51-
// This takes ownership of the #partInstanceIdObserver, and will stop it if this throws
5225
observer.#observers = await waitForAllObserversReady([
5326
ExpectedPackages.observeChanges(
5427
{
@@ -59,60 +32,16 @@ export class ExpectedPackagesContentObserver implements Meteor.LiveQueryHandle {
5932
projection: expectedPackageDBFieldsSpecifier,
6033
}
6134
),
62-
63-
// RundownPlaylists.observeChanges(
64-
// {
65-
// studioId: studioId,
66-
// },
67-
// cache.RundownPlaylists.link(() => {
68-
// observer.updatePartInstanceIds()
69-
// }),
70-
// {
71-
// fields: rundownPlaylistFieldSpecifier,
72-
// }
73-
// ),
74-
75-
// observer.#partInstanceIdObserver,
7635
])
7736

7837
return observer
7938
}
8039

81-
// private updatePartInstanceIds = _.debounce(
82-
// Meteor.bindEnvironment(() => {
83-
// if (this.#disposed) return
84-
85-
// const newPartInstanceIdsSet = new Set<PartInstanceId>()
86-
87-
// this.#cache.RundownPlaylists.find({}).forEach((playlist) => {
88-
// if (playlist.activationId) {
89-
// if (playlist.nextPartInfo) {
90-
// newPartInstanceIdsSet.add(playlist.nextPartInfo.partInstanceId)
91-
// }
92-
// if (playlist.currentPartInfo) {
93-
// newPartInstanceIdsSet.add(playlist.currentPartInfo.partInstanceId)
94-
// }
95-
// }
96-
// })
97-
98-
// const newPartInstanceIds = Array.from(newPartInstanceIdsSet)
99-
100-
// if (!equivalentArrays(newPartInstanceIds, this.#partInstanceIds)) {
101-
// this.#partInstanceIds = newPartInstanceIds
102-
// // trigger the rundown group to restart
103-
// this.#partInstanceIdObserver.restart()
104-
// }
105-
// }),
106-
// REACTIVITY_DEBOUNCE
107-
// )
108-
10940
public get cache(): ExpectedPackagesContentCache {
11041
return this.#cache
11142
}
11243

11344
public stop = (): void => {
114-
// this.#disposed = true
115-
11645
this.#observers.forEach((observer) => observer.stop())
11746
}
11847
}

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

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -87,86 +87,6 @@ export async function updateCollectionForExpectedPackageIds(
8787
})
8888
}
8989

90-
// /**
91-
// * Regenerate the output for the provided PieceInstance `regenerateIds`, updating the data in `collection` as needed
92-
// * @param contentCache Cache of the database documents used
93-
// * @param studio Minimal studio document
94-
// * @param layerNameToDeviceIds Lookup table of package layers, to PeripheralDeviceIds the layer could be used with
95-
// * @param collection Output collection of the publication
96-
// * @param filterPlayoutDeviceIds PeripheralDeviceId filter applied to this publication
97-
// * @param regenerateIds Ids of PieceInstance documents to be recalculated
98-
// * @deprecated
99-
// */
100-
// // nocommit @deprecated
101-
// export async function updateCollectionForPieceInstanceIds(
102-
// contentCache: ReadonlyDeep<ExpectedPackagesContentCache>,
103-
// studio: Pick<DBStudio, StudioFields>,
104-
// layerNameToDeviceIds: Map<string, PeripheralDeviceId[]>,
105-
// packageContainers: Record<string, StudioPackageContainer>,
106-
// collection: CustomPublishCollection<PackageManagerExpectedPackage>,
107-
// filterPlayoutDeviceIds: ReadonlyDeep<PeripheralDeviceId[]> | undefined,
108-
// regenerateIds: Set<PieceInstanceId>
109-
// ): Promise<void> {
110-
// const updatedDocIds = new Set<PackageManagerExpectedPackageId>()
111-
// const missingPieceInstanceIds = new Set<PieceInstanceId>()
112-
113-
// for (const pieceInstanceId of regenerateIds) {
114-
// const pieceInstanceDoc = contentCache.PieceInstances.findOne(pieceInstanceId)
115-
// if (!pieceInstanceDoc) {
116-
// missingPieceInstanceIds.add(pieceInstanceId)
117-
// continue
118-
// }
119-
// if (!pieceInstanceDoc.piece?.expectedPackages) continue
120-
121-
// pieceInstanceDoc.piece.expectedPackages.forEach((expectedPackage, i) => {
122-
// const sanitisedPackageId = getExpectedPackageIdForPieceInstance(
123-
// pieceInstanceId,
124-
// expectedPackage._id || '__unnamed' + i
125-
// )
126-
127-
// // Map the expectedPackages onto their specified layer:
128-
// const allDeviceIds = new Set<PeripheralDeviceId>()
129-
// for (const layerName of expectedPackage.layers) {
130-
// const layerDeviceIds = layerNameToDeviceIds.get(layerName)
131-
// for (const deviceId of layerDeviceIds || []) {
132-
// allDeviceIds.add(deviceId)
133-
// }
134-
// }
135-
136-
// for (const deviceId of allDeviceIds) {
137-
// // Filter, keep only the routed mappings for this device:
138-
// if (filterPlayoutDeviceIds && !filterPlayoutDeviceIds.includes(deviceId)) continue
139-
140-
// const routedPackage = generateExpectedPackageForDevice(
141-
// studio,
142-
// {
143-
// ...expectedPackage,
144-
// _id: unprotectString(sanitisedPackageId),
145-
// },
146-
// deviceId,
147-
// pieceInstanceId,
148-
// Priorities.OTHER, // low priority
149-
// packageContainers
150-
// )
151-
152-
// updatedDocIds.add(routedPackage._id)
153-
// collection.replace(routedPackage)
154-
// }
155-
// })
156-
// }
157-
158-
// // Remove all documents for an ExpectedPackage that was regenerated, and no update was issues
159-
// collection.remove((doc) => {
160-
// if (!doc.pieceInstanceId) return false
161-
162-
// if (missingPieceInstanceIds.has(doc.pieceInstanceId)) return true
163-
164-
// if (updatedDocIds.has(doc._id) && !regenerateIds.has(doc.pieceInstanceId)) return true
165-
166-
// return false
167-
// })
168-
// }
169-
17090
enum Priorities {
17191
// Lower priorities are done first
17292

meteor/server/publications/packageManager/expectedPackages/publication.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ interface ExpectedPackagesPublicationUpdateProps {
3737
newCache: ExpectedPackagesContentCache
3838

3939
invalidateExpectedPackageIds?: ExpectedPackageId[]
40-
// invalidatePieceInstanceIds?: PieceInstanceId[]
4140
}
4241

4342
interface ExpectedPackagesPublicationState {
@@ -82,11 +81,6 @@ async function setupExpectedPackagesPublicationObservers(
8281
changed: (id) => triggerUpdate({ invalidateExpectedPackageIds: [protectString<ExpectedPackageId>(id)] }),
8382
removed: (id) => triggerUpdate({ invalidateExpectedPackageIds: [protectString<ExpectedPackageId>(id)] }),
8483
}),
85-
// contentCache.PieceInstances.find({}).observeChanges({
86-
// added: (id) => triggerUpdate({ invalidatePieceInstanceIds: [protectString<PieceInstanceId>(id)] }),
87-
// changed: (id) => triggerUpdate({ invalidatePieceInstanceIds: [protectString<PieceInstanceId>(id)] }),
88-
// removed: (id) => triggerUpdate({ invalidatePieceInstanceIds: [protectString<PieceInstanceId>(id)] }),
89-
// }),
9084

9185
Studios.observeChanges(
9286
args.studioId,
@@ -156,16 +150,13 @@ async function manipulateExpectedPackagesPublicationData(
156150
}
157151

158152
let regenerateExpectedPackageIds: Set<ExpectedPackageId>
159-
// let regeneratePieceInstanceIds: Set<PieceInstanceId>
160153
if (invalidateAllItems) {
161154
// force every piece to be regenerated
162155
collection.remove(null)
163156
regenerateExpectedPackageIds = new Set(state.contentCache.ExpectedPackages.find({}).map((p) => p._id))
164-
// regeneratePieceInstanceIds = new Set(state.contentCache.PieceInstances.find({}).map((p) => p._id))
165157
} else {
166158
// only regenerate the reported changes
167159
regenerateExpectedPackageIds = new Set(updateProps.invalidateExpectedPackageIds)
168-
// regeneratePieceInstanceIds = new Set(updateProps.invalidatePieceInstanceIds)
169160
}
170161

171162
await updateCollectionForExpectedPackageIds(
@@ -177,15 +168,6 @@ async function manipulateExpectedPackagesPublicationData(
177168
args.filterPlayoutDeviceIds,
178169
regenerateExpectedPackageIds
179170
)
180-
// await updateCollectionForPieceInstanceIds(
181-
// state.contentCache,
182-
// state.studio,
183-
// state.layerNameToDeviceIds,
184-
// state.packageContainers,
185-
// collection,
186-
// args.filterPlayoutDeviceIds,
187-
// regeneratePieceInstanceIds
188-
// )
189171
}
190172

191173
meteorCustomPublish(

0 commit comments

Comments
 (0)