Skip to content

Commit 5ef7c34

Browse files
committed
fix: avoid excessive applyAndValidateOverrides
1 parent 685364d commit 5ef7c34

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { CustomPublishCollection } from '../../../lib/customPublication'
1717
import { logger } from '../../../logging'
1818
import { ExpectedPackagesContentCache } from './contentCache'
1919
import type { StudioFields } from './publication'
20-
import { applyAndValidateOverrides } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
2120

2221
/**
2322
* Regenerate the output for the provided ExpectedPackage `regenerateIds`, updating the data in `collection` as needed
@@ -32,13 +31,13 @@ export async function updateCollectionForExpectedPackageIds(
3231
contentCache: ReadonlyDeep<ExpectedPackagesContentCache>,
3332
studio: Pick<DBStudio, StudioFields>,
3433
layerNameToDeviceIds: Map<string, PeripheralDeviceId[]>,
34+
packageContainers: Record<string, StudioPackageContainer>,
3535
collection: CustomPublishCollection<PackageManagerExpectedPackage>,
3636
filterPlayoutDeviceIds: ReadonlyDeep<PeripheralDeviceId[]> | undefined,
3737
regenerateIds: Set<ExpectedPackageId>
3838
): Promise<void> {
3939
const updatedDocIds = new Set<PackageManagerExpectedPackageId>()
4040
const missingExpectedPackageIds = new Set<ExpectedPackageId>()
41-
const packageContainers = applyAndValidateOverrides(studio.packageContainersWithOverrides).obj
4241

4342
for (const packageId of regenerateIds) {
4443
const packageDoc = contentCache.ExpectedPackages.findOne(packageId)
@@ -102,13 +101,13 @@ export async function updateCollectionForPieceInstanceIds(
102101
contentCache: ReadonlyDeep<ExpectedPackagesContentCache>,
103102
studio: Pick<DBStudio, StudioFields>,
104103
layerNameToDeviceIds: Map<string, PeripheralDeviceId[]>,
104+
packageContainers: Record<string, StudioPackageContainer>,
105105
collection: CustomPublishCollection<PackageManagerExpectedPackage>,
106106
filterPlayoutDeviceIds: ReadonlyDeep<PeripheralDeviceId[]> | undefined,
107107
regenerateIds: Set<PieceInstanceId>
108108
): Promise<void> {
109109
const updatedDocIds = new Set<PackageManagerExpectedPackageId>()
110110
const missingPieceInstanceIds = new Set<PieceInstanceId>()
111-
const packageContainers = applyAndValidateOverrides(studio.packageContainersWithOverrides).obj
112111

113112
for (const pieceInstanceId of regenerateIds) {
114113
const pieceInstanceDoc = contentCache.PieceInstances.findOne(pieceInstanceId)

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meteor } from 'meteor/meteor'
22
import { PeripheralDeviceReadAccess } from '../../../security/peripheralDevice'
3-
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
3+
import { DBStudio, StudioPackageContainer } from '@sofie-automation/corelib/dist/dataModel/Studio'
44
import {
55
TriggerUpdate,
66
meteorCustomPublish,
@@ -48,6 +48,7 @@ interface ExpectedPackagesPublicationUpdateProps {
4848
interface ExpectedPackagesPublicationState {
4949
studio: Pick<DBStudio, StudioFields> | undefined
5050
layerNameToDeviceIds: Map<string, PeripheralDeviceId[]>
51+
packageContainers: Record<string, StudioPackageContainer>
5152

5253
contentCache: ReadonlyDeep<ExpectedPackagesContentCache>
5354
}
@@ -122,6 +123,7 @@ async function manipulateExpectedPackagesPublicationData(
122123
const invalidateAllItems = !updateProps || updateProps.newCache || updateProps.invalidateStudio
123124

124125
if (!state.layerNameToDeviceIds) state.layerNameToDeviceIds = new Map()
126+
if (!state.packageContainers) state.packageContainers = {}
125127

126128
if (invalidateAllItems) {
127129
// Everything is invalid, reset everything
@@ -141,12 +143,14 @@ async function manipulateExpectedPackagesPublicationData(
141143
if (!state.studio) {
142144
logger.warn(`Pub.expectedPackagesForDevice: studio "${args.studioId}" not found!`)
143145
state.layerNameToDeviceIds = new Map()
146+
state.packageContainers = {}
144147
} else {
145148
const studioMappings = applyAndValidateOverrides(state.studio.mappingsWithOverrides).obj
146149
state.layerNameToDeviceIds = buildMappingsToDeviceIdMap(
147150
applyAndValidateOverrides(state.studio.routeSetsWithOverrides).obj,
148151
studioMappings
149152
)
153+
state.packageContainers = applyAndValidateOverrides(state.studio.packageContainersWithOverrides).obj
150154
}
151155
}
152156

@@ -173,6 +177,7 @@ async function manipulateExpectedPackagesPublicationData(
173177
state.contentCache,
174178
state.studio,
175179
state.layerNameToDeviceIds,
180+
state.packageContainers,
176181
collection,
177182
args.filterPlayoutDeviceIds,
178183
regenerateExpectedPackageIds
@@ -181,6 +186,7 @@ async function manipulateExpectedPackagesPublicationData(
181186
state.contentCache,
182187
state.studio,
183188
state.layerNameToDeviceIds,
189+
state.packageContainers,
184190
collection,
185191
args.filterPlayoutDeviceIds,
186192
regeneratePieceInstanceIds

0 commit comments

Comments
 (0)