Skip to content

Commit e69a4fc

Browse files
Julusianolzzon
andcommitted
feat: processIngestData & userEditOperations
Co-authored-by: olzzon <[email protected]>
1 parent 132ebc0 commit e69a4fc

File tree

118 files changed

+10701
-3130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+10701
-3130
lines changed

meteor/__mocks__/defaultCollectionObjects.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export function defaultSegment(_id: SegmentId, rundownId: RundownId): DBSegment
134134
externalId: unprotectString(_id),
135135
rundownId: rundownId,
136136
name: 'Default Segment',
137-
externalModified: 1,
138137
}
139138
}
140139

meteor/__mocks__/helpers/database.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ import {
1414
SourceLayerType,
1515
StudioBlueprintManifest,
1616
BlueprintManifestType,
17-
IngestRundown,
1817
BlueprintManifestBase,
1918
ShowStyleBlueprintManifest,
2019
IShowStyleContext,
2120
BlueprintResultRundown,
2221
BlueprintResultSegment,
23-
IngestSegment,
2422
IBlueprintAdLibPiece,
2523
IBlueprintRundown,
2624
IBlueprintSegment,
@@ -32,6 +30,8 @@ import {
3230
StatusCode,
3331
IBlueprintPieceType,
3432
IBlueprintActionManifest,
33+
SofieIngestSegment,
34+
SofieIngestRundown,
3535
} from '@sofie-automation/blueprints-integration'
3636
import { DBShowStyleBase } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
3737
import { DBShowStyleVariant } from '@sofie-automation/corelib/dist/dataModel/ShowStyleVariant'
@@ -429,7 +429,10 @@ export async function setupMockShowStyleBlueprint(
429429
getShowStyleVariantId: (): string | null => {
430430
return SHOW_STYLE_VARIANT_ID
431431
},
432-
getRundown: (_context: IShowStyleContext, ingestRundown: IngestRundown): BlueprintResultRundown => {
432+
getRundown: (
433+
_context: IShowStyleContext,
434+
ingestRundown: SofieIngestRundown<any, any, any>
435+
): BlueprintResultRundown => {
433436
const rundown: IBlueprintRundown = {
434437
externalId: ingestRundown.externalId,
435438
name: ingestRundown.name,
@@ -452,7 +455,10 @@ export async function setupMockShowStyleBlueprint(
452455
baseline: { timelineObjects: [] },
453456
}
454457
},
455-
getSegment: (_context: unknown, ingestSegment: IngestSegment): BlueprintResultSegment => {
458+
getSegment: (
459+
_context: unknown,
460+
ingestSegment: SofieIngestSegment<any, any>
461+
): BlueprintResultSegment => {
456462
const segment: IBlueprintSegment = {
457463
name: ingestSegment.name ? ingestSegment.name : ingestSegment.externalId,
458464
privateData: ingestSegment.payload,
@@ -654,7 +660,6 @@ export async function setupDefaultRundown(
654660
externalId: 'MOCK_SEGMENT_0',
655661
rundownId: rundown._id,
656662
name: 'Segment 0',
657-
externalModified: 1,
658663
}
659664
await Segments.mutableCollection.insertAsync(segment0)
660665
/* tslint:disable:ter-indent*/
@@ -764,7 +769,6 @@ export async function setupDefaultRundown(
764769
externalId: 'MOCK_SEGMENT_2',
765770
rundownId: rundown._id,
766771
name: 'Segment 1',
767-
externalModified: 1,
768772
}
769773
await Segments.mutableCollection.insertAsync(segment1)
770774

@@ -807,7 +811,6 @@ export async function setupDefaultRundown(
807811
externalId: 'MOCK_SEGMENT_2',
808812
rundownId: rundown._id,
809813
name: 'Segment 2',
810-
externalModified: 1,
811814
}
812815
await Segments.mutableCollection.insertAsync(segment2)
813816

meteor/server/__tests__/_testEnvironment.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Evaluations,
1212
ExpectedMediaItems,
1313
ExternalMessageQueue,
14-
IngestDataCache,
14+
NrcsIngestDataCache,
1515
MediaObjects,
1616
MediaWorkFlows,
1717
MediaWorkFlowSteps,
@@ -74,7 +74,7 @@ describe('Basic test of test environment', () => {
7474
// @ts-ignore
7575
expect(ExternalMessageQueue._isMock).toBeTruthy()
7676
// @ts-ignore
77-
expect(IngestDataCache._isMock).toBeTruthy()
77+
expect(NrcsIngestDataCache._isMock).toBeTruthy()
7878
// @ts-ignore
7979
expect(MediaObjects._isMock).toBeTruthy()
8080
// @ts-ignore

meteor/server/__tests__/cronjobs.test.ts

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceIns
1919
import { Meteor } from 'meteor/meteor'
2020
import { EmptyPieceTimelineObjectsBlob } from '@sofie-automation/corelib/dist/dataModel/Piece'
2121
import {
22-
IngestDataCacheObjId,
22+
NrcsIngestDataCacheObjId,
23+
SofieIngestDataCacheObjId,
2324
PartId,
2425
PeripheralDeviceId,
2526
RundownId,
@@ -42,7 +43,7 @@ import '../cronjobs'
4243
import '../api/peripheralDevice'
4344
import {
4445
CoreSystem,
45-
IngestDataCache,
46+
NrcsIngestDataCache,
4647
PartInstances,
4748
Parts,
4849
PeripheralDeviceCommands,
@@ -51,8 +52,9 @@ import {
5152
Snapshots,
5253
UserActionsLog,
5354
Segments,
55+
SofieIngestDataCache,
5456
} from '../collections'
55-
import { IngestCacheType } from '@sofie-automation/corelib/dist/dataModel/IngestDataCache'
57+
import { NrcsIngestCacheType } from '@sofie-automation/corelib/dist/dataModel/NrcsIngestDataCache'
5658
import { JSONBlobStringify } from '@sofie-automation/shared-lib/dist/lib/JSONBlob'
5759
import {
5860
DefaultEnvironment,
@@ -61,6 +63,7 @@ import {
6163
} from '../../__mocks__/helpers/database'
6264
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
6365
import { Settings } from '../Settings'
66+
import { SofieIngestCacheType } from '@sofie-automation/corelib/dist/dataModel/SofieIngestDataCache'
6467

6568
describe('cronjobs', () => {
6669
let env: DefaultEnvironment
@@ -170,45 +173,95 @@ describe('cronjobs', () => {
170173
await PeripheralDevices.removeAsync({})
171174
})
172175

173-
testInFiber('Remove IngestDataCache objects that are not connected to any Rundown', async () => {
174-
// Set up a mock rundown, a detached IngestDataCache object and an object attached to the mock rundown
175-
// Detached IngestDataCache object 0
176-
const dataCache0Id = protectString<IngestDataCacheObjId>(getRandomString())
177-
await IngestDataCache.mutableCollection.insertAsync({
176+
testInFiber('Remove NrcsIngestDataCache objects that are not connected to any Rundown', async () => {
177+
// Set up a mock rundown, a detached NrcsIngestDataCache object and an object attached to the mock rundown
178+
// Detached NrcsIngestDataCache object 0
179+
const dataCache0Id = protectString<NrcsIngestDataCacheObjId>(getRandomString())
180+
await NrcsIngestDataCache.mutableCollection.insertAsync({
178181
_id: dataCache0Id,
179182
data: {
180183
externalId: '',
181184
name: '',
182185
segments: [],
183186
type: '',
187+
rundownSource: {} as any,
188+
payload: undefined,
184189
},
185190
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
186191
// this one is attached to rundown0
187192
rundownId: getRandomId(),
188-
type: IngestCacheType.RUNDOWN,
193+
type: NrcsIngestCacheType.RUNDOWN,
189194
})
190-
// Attached IngestDataCache object 1
191-
const dataCache1Id = protectString<IngestDataCacheObjId>(getRandomString())
192-
await IngestDataCache.mutableCollection.insertAsync({
195+
// Attached NrcsIngestDataCache object 1
196+
const dataCache1Id = protectString<NrcsIngestDataCacheObjId>(getRandomString())
197+
await NrcsIngestDataCache.mutableCollection.insertAsync({
193198
_id: dataCache1Id,
194199
data: {
195200
externalId: '',
196201
name: '',
197202
segments: [],
198203
type: '',
204+
rundownSource: {} as any,
205+
payload: undefined,
199206
},
200207
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
201208
// just some random ID
202209
rundownId: rundownId,
203-
type: IngestCacheType.RUNDOWN,
210+
type: NrcsIngestCacheType.RUNDOWN,
204211
})
205212

206213
await runCronjobs()
207214

208-
expect(await IngestDataCache.findOneAsync(dataCache1Id)).toMatchObject({
215+
expect(await NrcsIngestDataCache.findOneAsync(dataCache1Id)).toMatchObject({
209216
_id: dataCache1Id,
210217
})
211-
expect(await IngestDataCache.findOneAsync(dataCache0Id)).toBeUndefined()
218+
expect(await NrcsIngestDataCache.findOneAsync(dataCache0Id)).toBeUndefined()
219+
})
220+
testInFiber('Remove SofieIngestDataCache objects that are not connected to any Rundown', async () => {
221+
// Set up a mock rundown, a detached SofieIngestDataCache object and an object attached to the mock rundown
222+
// Detached SofieIngestDataCache object 0
223+
const dataCache0Id = protectString<SofieIngestDataCacheObjId>(getRandomString())
224+
await SofieIngestDataCache.mutableCollection.insertAsync({
225+
_id: dataCache0Id,
226+
data: {
227+
externalId: '',
228+
name: '',
229+
segments: [],
230+
type: '',
231+
rundownSource: {} as any,
232+
userEditStates: {},
233+
payload: undefined,
234+
},
235+
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
236+
// this one is attached to rundown0
237+
rundownId: getRandomId(),
238+
type: SofieIngestCacheType.RUNDOWN,
239+
})
240+
// Attached SofieIngestDataCache object 1
241+
const dataCache1Id = protectString<SofieIngestDataCacheObjId>(getRandomString())
242+
await SofieIngestDataCache.mutableCollection.insertAsync({
243+
_id: dataCache1Id,
244+
data: {
245+
externalId: '',
246+
name: '',
247+
segments: [],
248+
type: '',
249+
rundownSource: {} as any,
250+
userEditStates: {},
251+
payload: undefined,
252+
},
253+
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
254+
// just some random ID
255+
rundownId: rundownId,
256+
type: SofieIngestCacheType.RUNDOWN,
257+
})
258+
259+
await runCronjobs()
260+
261+
expect(await SofieIngestDataCache.findOneAsync(dataCache1Id)).toMatchObject({
262+
_id: dataCache1Id,
263+
})
264+
expect(await SofieIngestDataCache.findOneAsync(dataCache0Id)).toBeUndefined()
212265
})
213266
testInFiber('Removes old PartInstances and PieceInstances', async () => {
214267
// nightlyCronjobInner()
@@ -217,7 +270,6 @@ describe('cronjobs', () => {
217270
_id: getRandomId<SegmentId>(),
218271
_rank: 0,
219272
externalId: '',
220-
externalModified: 0,
221273
rundownId,
222274
name: 'mock segment',
223275
}

meteor/server/api/__tests__/cleanup.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
ExpectedPackageWorkStatuses,
3333
ExpectedPlayoutItems,
3434
ExternalMessageQueue,
35-
IngestDataCache,
35+
NrcsIngestDataCache,
3636
PackageContainerPackageStatuses,
3737
PackageInfos,
3838
PeripheralDeviceCommands,
@@ -45,6 +45,7 @@ import {
4545
TranslationsBundles,
4646
PackageContainerStatuses,
4747
TimelineDatastore,
48+
SofieIngestDataCache,
4849
} from '../../collections'
4950
import { Collections } from '../../collections/lib'
5051
import { generateTranslationBundleOriginId } from '../translationsBundles'
@@ -300,7 +301,14 @@ async function setDefaultDatatoDB(env: DefaultEnvironment, now: number) {
300301
tryCount: 0,
301302
type: '' as any,
302303
})
303-
await IngestDataCache.mutableCollection.insertAsync({
304+
await NrcsIngestDataCache.mutableCollection.insertAsync({
305+
_id: getRandomId(),
306+
data: {} as any,
307+
modified: 0,
308+
rundownId,
309+
type: '' as any,
310+
})
311+
await SofieIngestDataCache.mutableCollection.insertAsync({
304312
_id: getRandomId(),
305313
data: {} as any,
306314
modified: 0,

meteor/server/api/__tests__/peripheralDevice.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ describe('test peripheralDevice general API methods', () => {
120120
_rank: 0,
121121
rundownId: rundownID,
122122
name: 'Fire',
123-
externalModified: 1,
124123
})
125124
await Parts.mutableCollection.insertAsync({
126125
_id: protectString('part000'),
@@ -164,15 +163,13 @@ describe('test peripheralDevice general API methods', () => {
164163
externalId: 'segment01',
165164
rundownId: rundownID,
166165
name: 'Water',
167-
externalModified: 1,
168166
})
169167
await Segments.mutableCollection.insertAsync({
170168
_id: protectString('segment2'),
171169
_rank: 2,
172170
externalId: 'segment02',
173171
rundownId: rundownID,
174172
name: 'Earth',
175-
externalModified: 1,
176173
})
177174
})
178175
beforeEach(async () => {

meteor/server/api/cleanup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
ExpectedPackageWorkStatuses,
3838
ExpectedPlayoutItems,
3939
ExternalMessageQueue,
40-
IngestDataCache,
40+
NrcsIngestDataCache,
4141
MediaObjects,
4242
MediaWorkFlows,
4343
MediaWorkFlowSteps,
@@ -69,6 +69,7 @@ import {
6969
UserActionsLog,
7070
Workers,
7171
WorkerThreadStatuses,
72+
SofieIngestDataCache,
7273
} from '../collections'
7374
import { AsyncOnlyMongoCollection, AsyncOnlyReadOnlyMongoCollection } from '../collections/collection'
7475
import { getCollectionKey } from '../collections/lib'
@@ -276,7 +277,8 @@ export async function cleanupOldDataInner(actuallyCleanup = false): Promise<Coll
276277
}
277278
await ownedByRundownId(AdLibActions)
278279
await ownedByRundownId(AdLibPieces)
279-
await ownedByRundownId(IngestDataCache)
280+
await ownedByRundownId(SofieIngestDataCache)
281+
await ownedByRundownId(NrcsIngestDataCache)
280282
;(await ownedByRundownId(Parts)).forEach((id) => removedParts.add(id))
281283
await ownedByRundownId(RundownBaselineAdLibActions)
282284
await ownedByRundownId(RundownBaselineAdLibPieces)

0 commit comments

Comments
 (0)