Skip to content

Commit

Permalink
chore: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Waller committed Oct 6, 2023
1 parent 503b031 commit 32909ed
Show file tree
Hide file tree
Showing 32 changed files with 218 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import {
EmptyPieceTimelineObjectsBlob,
serializePieceTimelineObjectsBlob,
} from '@sofie-automation/corelib/dist/dataModel/Piece'
import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces'
import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel'
import { convertPartInstanceToBlueprints, convertPieceInstanceToBlueprints } from '../context/lib'
import { TimelineObjRundown, TimelineObjType } from '@sofie-automation/corelib/dist/dataModel/Timeline'
import { PartInstanceWithPiecesImpl } from '../../playout/cacheModel/implementation/PartInstanceWithPiecesImpl'
import { PlayoutPartInstanceModelImpl } from '../../playout/cacheModel/implementation/PlayoutPartInstanceModelImpl'
import { writePartInstancesAndPieceInstances } from '../../playout/cacheModel/implementation/SavePlayoutModel'

import * as PlayoutAdlib from '../../playout/adlibUtils'
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('Test blueprint api context', () => {
context: MockJobContext,
activationId: RundownPlaylistActivationId,
rundownId: RundownId
): Promise<PartInstanceWithPieces[]> {
): Promise<PlayoutPartInstanceModel[]> {
const parts = await context.mockCollections.Parts.findFetch({ rundownId })
for (let i = 0; i < parts.length; i++) {
const part = parts[i]
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Test blueprint api context', () => {
const pieceInstances = await context.mockCollections.PieceInstances.findFetch({
partInstanceId: partInstance._id,
})
return new PartInstanceWithPiecesImpl(partInstance, pieceInstances, false)
return new PlayoutPartInstanceModelImpl(partInstance, pieceInstances, false)
})
)
}
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('Test blueprint api context', () => {
jobContext: MockJobContext
playlistId: RundownPlaylistId
rundownId: RundownId
allPartInstances: PartInstanceWithPieces[]
allPartInstances: PlayoutPartInstanceModel[]
}> {
const context = setupDefaultJobEnvironment()

Expand Down Expand Up @@ -230,13 +230,13 @@ describe('Test blueprint api context', () => {
async function saveAllToDatabase(
context: JobContext,
cache: PlayoutModel,
allPartInstances: PartInstanceWithPieces[]
allPartInstances: PlayoutPartInstanceModel[]
) {
// We need to push changes back to 'mongo' for these tests
await Promise.all(
writePartInstancesAndPieceInstances(
context,
normalizeArrayToMapFunc(allPartInstances as PartInstanceWithPiecesImpl[], (p) => p.PartInstance._id)
normalizeArrayToMapFunc(allPartInstances as PlayoutPartInstanceModelImpl[], (p) => p.PartInstance._id)
)
)
await cache.saveAllToDatabase()
Expand All @@ -245,11 +245,11 @@ describe('Test blueprint api context', () => {
async function setPartInstances(
jobContext: MockJobContext,
playlistId: RundownPlaylistId,
currentPartInstance: PartInstanceWithPieces | DBPartInstance | PieceInstance | undefined | null,
nextPartInstance: PartInstanceWithPieces | DBPartInstance | PieceInstance | undefined | null,
previousPartInstance?: PartInstanceWithPieces | DBPartInstance | PieceInstance | null
currentPartInstance: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | undefined | null,
nextPartInstance: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | undefined | null,
previousPartInstance?: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | null
) {
const convertInfo = (info: PartInstanceWithPieces | DBPartInstance | PieceInstance | null) => {
const convertInfo = (info: PlayoutPartInstanceModel | DBPartInstance | PieceInstance | null) => {
if (!info) {
return null
} else if ('partInstanceId' in info) {
Expand Down Expand Up @@ -452,7 +452,7 @@ describe('Test blueprint api context', () => {
(
context2: JobContext,
sourceLayers: SourceLayers,
partInstance: PartInstanceWithPieces,
partInstance: PlayoutPartInstanceModel,
now?: number
) => {
expect(context2).toBe(jobContext)
Expand Down Expand Up @@ -1242,7 +1242,7 @@ describe('Test blueprint api context', () => {

// Ensure there are no pending updates already
for (const partInstance of cache.LoadedPartInstances) {
expect((partInstance as PartInstanceWithPiecesImpl).HasChanges).toBeFalsy()
expect((partInstance as PlayoutPartInstanceModelImpl).HasChanges).toBeFalsy()
}

// Update it and expect it to match
Expand Down Expand Up @@ -1289,7 +1289,7 @@ describe('Test blueprint api context', () => {
},
}
expect(pieceInstance1).toEqual(pieceInstance0After)
expect((partInstance1 as PartInstanceWithPiecesImpl).HasChanges).toBeTruthy()
expect((partInstance1 as PlayoutPartInstanceModelImpl).HasChanges).toBeTruthy()
// expect(
// Array.from(cache.PieceInstances.documents.values()).filter((doc) => !doc || !!doc.updated)
// ).toMatchObject([
Expand Down Expand Up @@ -1380,7 +1380,7 @@ describe('Test blueprint api context', () => {
playOffset: 0,
take: undefined,
}
cache.replacePartInstance(new PartInstanceWithPiecesImpl(partInstance, [], true))
cache.replacePartInstance(new PlayoutPartInstanceModelImpl(partInstance, [], true))

expect(isTooCloseToAutonext(partInstance, true)).toBeTruthy()
await expect(context.queuePart({} as any, [{}] as any)).rejects.toThrow(
Expand Down Expand Up @@ -1720,7 +1720,7 @@ describe('Test blueprint api context', () => {
const { context } = await getActionExecutionContext(jobContext, cache)

// Ensure there are no pending updates already
expect((cache.NextPartInstance! as PartInstanceWithPiecesImpl).HasChanges).toBeFalsy()
expect((cache.NextPartInstance! as PlayoutPartInstanceModelImpl).HasChanges).toBeFalsy()

// Update it and expect it to match
const partInstance0Before = clone(partInstance0)
Expand All @@ -1745,7 +1745,7 @@ describe('Test blueprint api context', () => {
},
}
expect(partInstance1.PartInstance).toEqual(pieceInstance0After)
expect((partInstance1 as PartInstanceWithPiecesImpl).HasChanges).toBeTruthy()
expect((partInstance1 as PlayoutPartInstanceModelImpl).HasChanges).toBeTruthy()
// expect(
// Array.from(cache.PartInstances.documents.values()).filter((doc) => !doc || !!doc.updated)
// ).toMatchObject([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PieceInstanceId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { PieceInstance, PieceInstancePiece } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
import { clone, normalizeArrayToMap, omit } from '@sofie-automation/corelib/dist/lib'
import { protectString, protectStringArray, unprotectStringArray } from '@sofie-automation/corelib/dist/protectedString'
import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces'
import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel'
import { ReadonlyDeep } from 'type-fest'
import _ = require('underscore')
import { ContextInfo } from './CommonContext'
Expand Down Expand Up @@ -39,15 +39,15 @@ export class SyncIngestUpdateToPartInstanceContext
{
private readonly _proposedPieceInstances: Map<PieceInstanceId, ReadonlyDeep<PieceInstance>>

private partInstance: PartInstanceWithPieces | null
private partInstance: PlayoutPartInstanceModel | null

constructor(
private readonly _context: JobContext,
contextInfo: ContextInfo,
studio: ReadonlyDeep<DBStudio>,
showStyleCompound: ReadonlyDeep<ProcessedShowStyleCompound>,
rundown: ReadonlyDeep<DBRundown>,
partInstance: PartInstanceWithPieces,
partInstance: PlayoutPartInstanceModel,
proposedPieceInstances: ReadonlyDeep<PieceInstance[]>,
private playStatus: 'previous' | 'current' | 'next'
) {
Expand Down
10 changes: 5 additions & 5 deletions packages/job-worker/src/blueprints/context/adlibActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { assertNever, getRandomId, omit } from '@sofie-automation/corelib/dist/l
import { logger } from '../../logging'
import { ReadonlyDeep } from 'type-fest'
import { PlayoutModel } from '../../playout/cacheModel/PlayoutModel'
import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces'
import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel'
import { UserContextInfo } from './CommonContext'
import { ShowStyleUserContext } from './ShowStyleUserContext'
import { WatchedPackagesHelper } from './watchedPackages'
Expand Down Expand Up @@ -66,7 +66,7 @@ import { ProcessedShowStyleConfig } from '../config'
import { DatastorePersistenceMode } from '@sofie-automation/shared-lib/dist/core/model/TimelineDatastore'
import { getDatastoreId } from '../../playout/datastore'
import { executePeripheralDeviceAction, listPlayoutDevices } from '../../peripheralDevice'
import { RundownWithSegments } from '../../playout/cacheModel/RundownWithSegments'
import { PlayoutRundownModel } from '../../playout/cacheModel/PlayoutRundownModel'

export enum ActionPartChange {
NONE = 0,
Expand Down Expand Up @@ -123,7 +123,7 @@ export class DatastoreActionExecutionContext
export class ActionExecutionContext extends ShowStyleUserContext implements IActionExecutionContext, IEventContext {
private readonly _context: JobContext
private readonly _cache: PlayoutModel
private readonly rundown: RundownWithSegments
private readonly rundown: PlayoutRundownModel

/** To be set by any mutation methods on this context. Indicates to core how extensive the changes are to the current partInstance */
public currentPartState: ActionPartChange = ActionPartChange.NONE
Expand All @@ -138,7 +138,7 @@ export class ActionExecutionContext extends ShowStyleUserContext implements IAct
cache: PlayoutModel,
showStyle: ReadonlyDeep<ProcessedShowStyleCompound>,
_showStyleBlueprintConfig: ProcessedShowStyleConfig,
rundown: RundownWithSegments,
rundown: PlayoutRundownModel,
watchedPackages: WatchedPackagesHelper
) {
super(contextInfo, context, showStyle, watchedPackages)
Expand All @@ -148,7 +148,7 @@ export class ActionExecutionContext extends ShowStyleUserContext implements IAct
this.takeAfterExecute = false
}

private _getPartInstance(part: 'current' | 'next'): PartInstanceWithPieces | null {
private _getPartInstance(part: 'current' | 'next'): PlayoutPartInstanceModel | null {
switch (part) {
case 'current':
return this._cache.CurrentPartInstance
Expand Down
4 changes: 2 additions & 2 deletions packages/job-worker/src/ingest/__tests__/ingest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { innerStartQueuedAdLib } from '../../playout/adlibUtils'
import { IngestJobs, RemoveOrphanedSegmentsProps } from '@sofie-automation/corelib/dist/worker/ingest'
import { removeRundownPlaylistFromDb } from './lib'
import { UserErrorMessage } from '@sofie-automation/corelib/dist/error'
import { PartInstanceWithPieces } from '../../playout/cacheModel/PartInstanceWithPieces'
import { PlayoutPartInstanceModel } from '../../playout/cacheModel/PlayoutPartInstanceModel'

require('../../peripheralDevice.ts') // include in order to create the Meteor methods needed

Expand Down Expand Up @@ -2009,7 +2009,7 @@ describe('Test ingest actions for rundowns and segments', () => {
const rundown0 = cache.Rundowns[0]
expect(rundown0).toBeTruthy()

const currentPartInstance = cache.CurrentPartInstance as PartInstanceWithPieces
const currentPartInstance = cache.CurrentPartInstance as PlayoutPartInstanceModel
expect(currentPartInstance).toBeTruthy()

const newPartInstance = cache.insertAdlibbedPartInstance({
Expand Down
14 changes: 7 additions & 7 deletions packages/job-worker/src/ingest/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
import { unprotectString, protectString } from '@sofie-automation/corelib/dist/protectedString'
import { logger } from '../logging'
import { PlayoutModel } from '../playout/cacheModel/PlayoutModel'
import { RundownWithSegments } from '../playout/cacheModel/RundownWithSegments'
import { PlayoutRundownModel } from '../playout/cacheModel/PlayoutRundownModel'
import { isTooCloseToAutonext } from '../playout/lib'
import { allowedToMoveRundownOutOfPlaylist, updatePartInstanceRanks } from '../rundown'
import {
Expand Down Expand Up @@ -42,8 +42,8 @@ import {
SegmentOrphanedReason,
} from '@sofie-automation/corelib/dist/dataModel/Segment'
import { UserError, UserErrorMessage } from '@sofie-automation/corelib/dist/error'
import { RundownWithSegmentsImpl } from '../playout/cacheModel/implementation/RundownWithSegmentsImpl'
import { SegmentWithPartsImpl } from '../playout/cacheModel/implementation/SegmentWithPartsImpl'
import { PlayoutRundownModelImpl } from '../playout/cacheModel/implementation/PlayoutRundownModelImpl'
import { PlayoutSegmentModelImpl } from '../playout/cacheModel/implementation/PlayoutSegmentModelImpl'
import { ReadOnlyCache } from '../cache/CacheBase'
import { createPlayoutCachefromIngestCache } from '../playout/cacheModel/implementation/LoadPlayoutModel'

Expand Down Expand Up @@ -344,27 +344,27 @@ async function updatePartInstancesSegmentIds(
}
}

export function hackConvertIngestCacheToRundownWithSegments(cache: ReadOnlyCache<CacheForIngest>): RundownWithSegments {
export function hackConvertIngestCacheToRundownWithSegments(cache: ReadOnlyCache<CacheForIngest>): PlayoutRundownModel {
const rundown = cache.Rundown.doc
if (!rundown) {
throw new Error(`Rundown "${cache.RundownId}" ("${cache.RundownExternalId}") not found`)
}

const groupedParts = groupByToMap(cache.Parts.findAll(null), 'segmentId')
const segmentsWithParts = cache.Segments.findAll(null).map(
(segment) => new SegmentWithPartsImpl(segment, groupedParts.get(segment._id) ?? [])
(segment) => new PlayoutSegmentModelImpl(segment, groupedParts.get(segment._id) ?? [])
)
const groupedSegmentsWithParts = groupByToMapFunc(segmentsWithParts, (s) => s.Segment.rundownId)

return new RundownWithSegmentsImpl(rundown, groupedSegmentsWithParts.get(rundown._id) ?? [], [])
return new PlayoutRundownModelImpl(rundown, groupedSegmentsWithParts.get(rundown._id) ?? [], [])
}

/**
* Ensure some 'basic' PartInstances properties are in sync with their parts
*/
async function updatePartInstancesBasicProperties(
context: JobContext,
rundownModel: RundownWithSegments,
rundownModel: PlayoutRundownModel,
playlist: ReadonlyDeep<DBRundownPlaylist>
) {
// Get a list of all the Parts that are known to exist
Expand Down
16 changes: 8 additions & 8 deletions packages/job-worker/src/ingest/syncChangesToPartInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BlueprintSyncIngestNewData, BlueprintSyncIngestPartInstance } from '@so
import { ReadOnlyCache } from '../cache/CacheBase'
import { JobContext } from '../jobs'
import { PlayoutModel } from '../playout/cacheModel/PlayoutModel'
import { PartInstanceWithPieces } from '../playout/cacheModel/PartInstanceWithPieces'
import { PlayoutPartInstanceModel } from '../playout/cacheModel/PlayoutPartInstanceModel'
import { CacheForIngest } from './cache'
import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartInstance'
Expand Down Expand Up @@ -32,8 +32,8 @@ import { hackConvertIngestCacheToRundownWithSegments } from './commit'

type PlayStatus = 'previous' | 'current' | 'next'
type SyncedInstance = {
existingPartInstance: PartInstanceWithPieces
previousPartInstance: PartInstanceWithPieces | null
existingPartInstance: PlayoutPartInstanceModel
previousPartInstance: PlayoutPartInstanceModel | null
playStatus: PlayStatus
newPart: ReadonlyDeep<DBPart> | undefined
piecesThatMayBeActive: Promise<Piece[]>
Expand Down Expand Up @@ -241,8 +241,8 @@ function insertToSyncedInstanceCandidates(
instances: SyncedInstance[],
cache: PlayoutModel,
ingestCache: ReadOnlyCache<CacheForIngest>,
thisPartInstance: PartInstanceWithPieces,
previousPartInstance: PartInstanceWithPieces | null,
thisPartInstance: PlayoutPartInstanceModel,
previousPartInstance: PlayoutPartInstanceModel | null,
part: ReadonlyDeep<DBPart> | undefined,
playStatus: PlayStatus
): void {
Expand All @@ -269,8 +269,8 @@ function findPartAndInsertToSyncedInstanceCandidates(
instances: SyncedInstance[],
cache: PlayoutModel,
ingestCache: ReadOnlyCache<CacheForIngest>,
thisPartInstance: PartInstanceWithPieces,
previousPartInstance: PartInstanceWithPieces | null,
thisPartInstance: PlayoutPartInstanceModel,
previousPartInstance: PlayoutPartInstanceModel | null,
playStatus: PlayStatus
): void {
const newPart = cache.findPart(thisPartInstance.PartInstance.part._id)
Expand All @@ -295,7 +295,7 @@ function findLastUnorphanedPartInstanceInSegment(
cache: PlayoutModel,
currentPartInstance: ReadonlyDeep<DBPartInstance>
): {
partInstance: PartInstanceWithPieces
partInstance: PlayoutPartInstanceModel
part: ReadonlyDeep<DBPart>
} | null {
// Find the "latest" (last played), non-orphaned PartInstance in this Segment, in this play-through
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
import { protectString } from '@sofie-automation/corelib/dist/protectedString'
import { ReadonlyDeep } from 'type-fest'
import { MockJobContext, setupDefaultJobEnvironment } from '../../__mocks__/context'
import { SegmentWithPartsImpl } from '../cacheModel/implementation/SegmentWithPartsImpl'
import { SegmentWithParts } from '../cacheModel/SegmentWithParts'
import { PlayoutSegmentModelImpl } from '../cacheModel/implementation/PlayoutSegmentModelImpl'
import { PlayoutSegmentModel } from '../cacheModel/PlayoutSegmentModel'
import { selectNextPart } from '../selectNextPart'

class MockPart {
Expand Down Expand Up @@ -71,9 +71,9 @@ describe('selectNextPart', () => {
ignoreUnplayabale = true
) {
const parts = [...(defaultParts as unknown as DBPart[])]
const segments: readonly SegmentWithParts[] = defaultSegments.map(
const segments: readonly PlayoutSegmentModel[] = defaultSegments.map(
(segment) =>
new SegmentWithPartsImpl(
new PlayoutSegmentModelImpl(
segment as unknown as DBSegment,
parts.filter((p) => p.segmentId === segment._id)
)
Expand Down
Loading

0 comments on commit 32909ed

Please sign in to comment.