Skip to content

Commit

Permalink
Merge branch 'upstream/process-ingest-data2' into release52
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/blueprints-integration/src/api/studio.ts
  • Loading branch information
nytamin committed Dec 10, 2024
2 parents 57ddfde + 6e04a7f commit f742fcb
Show file tree
Hide file tree
Showing 120 changed files with 10,790 additions and 3,141 deletions.
1 change: 0 additions & 1 deletion meteor/__mocks__/defaultCollectionObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export function defaultSegment(_id: SegmentId, rundownId: RundownId): DBSegment
externalId: unprotectString(_id),
rundownId: rundownId,
name: 'Default Segment',
externalModified: 1,
}
}

Expand Down
17 changes: 10 additions & 7 deletions meteor/__mocks__/helpers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ import {
SourceLayerType,
StudioBlueprintManifest,
BlueprintManifestType,
IngestRundown,
BlueprintManifestBase,
ShowStyleBlueprintManifest,
IShowStyleContext,
BlueprintResultRundown,
BlueprintResultSegment,
IngestSegment,
IBlueprintAdLibPiece,
IBlueprintRundown,
IBlueprintSegment,
Expand All @@ -32,6 +30,8 @@ import {
StatusCode,
IBlueprintPieceType,
IBlueprintActionManifest,
SofieIngestSegment,
SofieIngestRundown,
} from '@sofie-automation/blueprints-integration'
import { DBShowStyleBase } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
import { DBShowStyleVariant } from '@sofie-automation/corelib/dist/dataModel/ShowStyleVariant'
Expand Down Expand Up @@ -429,7 +429,10 @@ export async function setupMockShowStyleBlueprint(
getShowStyleVariantId: (): string | null => {
return SHOW_STYLE_VARIANT_ID
},
getRundown: (_context: IShowStyleContext, ingestRundown: IngestRundown): BlueprintResultRundown => {
getRundown: (
_context: IShowStyleContext,
ingestRundown: SofieIngestRundown<any, any, any>
): BlueprintResultRundown => {
const rundown: IBlueprintRundown = {
externalId: ingestRundown.externalId,
name: ingestRundown.name,
Expand All @@ -452,7 +455,10 @@ export async function setupMockShowStyleBlueprint(
baseline: { timelineObjects: [] },
}
},
getSegment: (_context: unknown, ingestSegment: IngestSegment): BlueprintResultSegment => {
getSegment: (
_context: unknown,
ingestSegment: SofieIngestSegment<any, any>
): BlueprintResultSegment => {
const segment: IBlueprintSegment = {
name: ingestSegment.name ? ingestSegment.name : ingestSegment.externalId,
privateData: ingestSegment.payload,
Expand Down Expand Up @@ -654,7 +660,6 @@ export async function setupDefaultRundown(
externalId: 'MOCK_SEGMENT_0',
rundownId: rundown._id,
name: 'Segment 0',
externalModified: 1,
}
await Segments.mutableCollection.insertAsync(segment0)
/* tslint:disable:ter-indent*/
Expand Down Expand Up @@ -764,7 +769,6 @@ export async function setupDefaultRundown(
externalId: 'MOCK_SEGMENT_2',
rundownId: rundown._id,
name: 'Segment 1',
externalModified: 1,
}
await Segments.mutableCollection.insertAsync(segment1)

Expand Down Expand Up @@ -807,7 +811,6 @@ export async function setupDefaultRundown(
externalId: 'MOCK_SEGMENT_2',
rundownId: rundown._id,
name: 'Segment 2',
externalModified: 1,
}
await Segments.mutableCollection.insertAsync(segment2)

Expand Down
4 changes: 2 additions & 2 deletions meteor/server/__tests__/_testEnvironment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Evaluations,
ExpectedMediaItems,
ExternalMessageQueue,
IngestDataCache,
NrcsIngestDataCache,
MediaObjects,
MediaWorkFlows,
MediaWorkFlowSteps,
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('Basic test of test environment', () => {
// @ts-ignore
expect(ExternalMessageQueue._isMock).toBeTruthy()
// @ts-ignore
expect(IngestDataCache._isMock).toBeTruthy()
expect(NrcsIngestDataCache._isMock).toBeTruthy()
// @ts-ignore
expect(MediaObjects._isMock).toBeTruthy()
// @ts-ignore
Expand Down
84 changes: 68 additions & 16 deletions meteor/server/__tests__/cronjobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceIns
import { Meteor } from 'meteor/meteor'
import { EmptyPieceTimelineObjectsBlob } from '@sofie-automation/corelib/dist/dataModel/Piece'
import {
IngestDataCacheObjId,
NrcsIngestDataCacheObjId,
SofieIngestDataCacheObjId,
PartId,
PeripheralDeviceId,
RundownId,
Expand All @@ -42,7 +43,7 @@ import '../cronjobs'
import '../api/peripheralDevice'
import {
CoreSystem,
IngestDataCache,
NrcsIngestDataCache,
PartInstances,
Parts,
PeripheralDeviceCommands,
Expand All @@ -51,8 +52,9 @@ import {
Snapshots,
UserActionsLog,
Segments,
SofieIngestDataCache,
} from '../collections'
import { IngestCacheType } from '@sofie-automation/corelib/dist/dataModel/IngestDataCache'
import { NrcsIngestCacheType } from '@sofie-automation/corelib/dist/dataModel/NrcsIngestDataCache'
import { JSONBlobStringify } from '@sofie-automation/shared-lib/dist/lib/JSONBlob'
import {
DefaultEnvironment,
Expand All @@ -61,6 +63,7 @@ import {
} from '../../__mocks__/helpers/database'
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
import { Settings } from '../Settings'
import { SofieIngestCacheType } from '@sofie-automation/corelib/dist/dataModel/SofieIngestDataCache'

describe('cronjobs', () => {
let env: DefaultEnvironment
Expand Down Expand Up @@ -170,45 +173,95 @@ describe('cronjobs', () => {
await PeripheralDevices.removeAsync({})
})

testInFiber('Remove IngestDataCache objects that are not connected to any Rundown', async () => {
// Set up a mock rundown, a detached IngestDataCache object and an object attached to the mock rundown
// Detached IngestDataCache object 0
const dataCache0Id = protectString<IngestDataCacheObjId>(getRandomString())
await IngestDataCache.mutableCollection.insertAsync({
testInFiber('Remove NrcsIngestDataCache objects that are not connected to any Rundown', async () => {
// Set up a mock rundown, a detached NrcsIngestDataCache object and an object attached to the mock rundown
// Detached NrcsIngestDataCache object 0
const dataCache0Id = protectString<NrcsIngestDataCacheObjId>(getRandomString())
await NrcsIngestDataCache.mutableCollection.insertAsync({
_id: dataCache0Id,
data: {
externalId: '',
name: '',
segments: [],
type: '',
rundownSource: {} as any,
payload: undefined,
},
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
// this one is attached to rundown0
rundownId: getRandomId(),
type: IngestCacheType.RUNDOWN,
type: NrcsIngestCacheType.RUNDOWN,
})
// Attached IngestDataCache object 1
const dataCache1Id = protectString<IngestDataCacheObjId>(getRandomString())
await IngestDataCache.mutableCollection.insertAsync({
// Attached NrcsIngestDataCache object 1
const dataCache1Id = protectString<NrcsIngestDataCacheObjId>(getRandomString())
await NrcsIngestDataCache.mutableCollection.insertAsync({
_id: dataCache1Id,
data: {
externalId: '',
name: '',
segments: [],
type: '',
rundownSource: {} as any,
payload: undefined,
},
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
// just some random ID
rundownId: rundownId,
type: IngestCacheType.RUNDOWN,
type: NrcsIngestCacheType.RUNDOWN,
})

await runCronjobs()

expect(await IngestDataCache.findOneAsync(dataCache1Id)).toMatchObject({
expect(await NrcsIngestDataCache.findOneAsync(dataCache1Id)).toMatchObject({
_id: dataCache1Id,
})
expect(await IngestDataCache.findOneAsync(dataCache0Id)).toBeUndefined()
expect(await NrcsIngestDataCache.findOneAsync(dataCache0Id)).toBeUndefined()
})
testInFiber('Remove SofieIngestDataCache objects that are not connected to any Rundown', async () => {
// Set up a mock rundown, a detached SofieIngestDataCache object and an object attached to the mock rundown
// Detached SofieIngestDataCache object 0
const dataCache0Id = protectString<SofieIngestDataCacheObjId>(getRandomString())
await SofieIngestDataCache.mutableCollection.insertAsync({
_id: dataCache0Id,
data: {
externalId: '',
name: '',
segments: [],
type: '',
rundownSource: {} as any,
userEditStates: {},
payload: undefined,
},
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
// this one is attached to rundown0
rundownId: getRandomId(),
type: SofieIngestCacheType.RUNDOWN,
})
// Attached SofieIngestDataCache object 1
const dataCache1Id = protectString<SofieIngestDataCacheObjId>(getRandomString())
await SofieIngestDataCache.mutableCollection.insertAsync({
_id: dataCache1Id,
data: {
externalId: '',
name: '',
segments: [],
type: '',
rundownSource: {} as any,
userEditStates: {},
payload: undefined,
},
modified: new Date(2000, 0, 1, 0, 0, 0).getTime(),
// just some random ID
rundownId: rundownId,
type: SofieIngestCacheType.RUNDOWN,
})

await runCronjobs()

expect(await SofieIngestDataCache.findOneAsync(dataCache1Id)).toMatchObject({
_id: dataCache1Id,
})
expect(await SofieIngestDataCache.findOneAsync(dataCache0Id)).toBeUndefined()
})
testInFiber('Removes old PartInstances and PieceInstances', async () => {
// nightlyCronjobInner()
Expand All @@ -217,7 +270,6 @@ describe('cronjobs', () => {
_id: getRandomId<SegmentId>(),
_rank: 0,
externalId: '',
externalModified: 0,
rundownId,
name: 'mock segment',
}
Expand Down
12 changes: 10 additions & 2 deletions meteor/server/api/__tests__/cleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
ExpectedPackageWorkStatuses,
ExpectedPlayoutItems,
ExternalMessageQueue,
IngestDataCache,
NrcsIngestDataCache,
PackageContainerPackageStatuses,
PackageInfos,
PeripheralDeviceCommands,
Expand All @@ -45,6 +45,7 @@ import {
TranslationsBundles,
PackageContainerStatuses,
TimelineDatastore,
SofieIngestDataCache,
} from '../../collections'
import { Collections } from '../../collections/lib'
import { generateTranslationBundleOriginId } from '../translationsBundles'
Expand Down Expand Up @@ -300,7 +301,14 @@ async function setDefaultDatatoDB(env: DefaultEnvironment, now: number) {
tryCount: 0,
type: '' as any,
})
await IngestDataCache.mutableCollection.insertAsync({
await NrcsIngestDataCache.mutableCollection.insertAsync({
_id: getRandomId(),
data: {} as any,
modified: 0,
rundownId,
type: '' as any,
})
await SofieIngestDataCache.mutableCollection.insertAsync({
_id: getRandomId(),
data: {} as any,
modified: 0,
Expand Down
3 changes: 0 additions & 3 deletions meteor/server/api/__tests__/peripheralDevice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ describe('test peripheralDevice general API methods', () => {
_rank: 0,
rundownId: rundownID,
name: 'Fire',
externalModified: 1,
})
await Parts.mutableCollection.insertAsync({
_id: protectString('part000'),
Expand Down Expand Up @@ -164,15 +163,13 @@ describe('test peripheralDevice general API methods', () => {
externalId: 'segment01',
rundownId: rundownID,
name: 'Water',
externalModified: 1,
})
await Segments.mutableCollection.insertAsync({
_id: protectString('segment2'),
_rank: 2,
externalId: 'segment02',
rundownId: rundownID,
name: 'Earth',
externalModified: 1,
})
})
beforeEach(async () => {
Expand Down
6 changes: 4 additions & 2 deletions meteor/server/api/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
ExpectedPackageWorkStatuses,
ExpectedPlayoutItems,
ExternalMessageQueue,
IngestDataCache,
NrcsIngestDataCache,
MediaObjects,
MediaWorkFlows,
MediaWorkFlowSteps,
Expand Down Expand Up @@ -69,6 +69,7 @@ import {
UserActionsLog,
Workers,
WorkerThreadStatuses,
SofieIngestDataCache,
} from '../collections'
import { AsyncOnlyMongoCollection, AsyncOnlyReadOnlyMongoCollection } from '../collections/collection'
import { getCollectionKey } from '../collections/lib'
Expand Down Expand Up @@ -276,7 +277,8 @@ export async function cleanupOldDataInner(actuallyCleanup = false): Promise<Coll
}
await ownedByRundownId(AdLibActions)
await ownedByRundownId(AdLibPieces)
await ownedByRundownId(IngestDataCache)
await ownedByRundownId(SofieIngestDataCache)
await ownedByRundownId(NrcsIngestDataCache)
;(await ownedByRundownId(Parts)).forEach((id) => removedParts.add(id))
await ownedByRundownId(RundownBaselineAdLibActions)
await ownedByRundownId(RundownBaselineAdLibPieces)
Expand Down
1 change: 1 addition & 0 deletions meteor/server/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export namespace ServerClientAPI {

class ServerClientAPIClass extends MethodContextAPI implements NewClientAPI {
async clientLogger(type: string, ...args: string[]): Promise<void> {
triggerWriteAccessBecauseNoCheckNecessary()
const loggerFunction: LeveledLogMethodFixed = (logger as any)[type] || logger.log

loggerFunction(args.join(', '))
Expand Down
Loading

0 comments on commit f742fcb

Please sign in to comment.