Skip to content

Commit 2fda2b4

Browse files
committed
wip: some statuses are piped through now
1 parent 7af2a8a commit 2fda2b4

File tree

11 files changed

+222
-224
lines changed

11 files changed

+222
-224
lines changed

meteor/server/publications/ingestStatus/publication.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function setupIngestRundownStatusPublicationObservers(
4343
triggerUpdate: TriggerUpdate<IngestRundownStatusUpdateProps>
4444
): Promise<SetupObserversResult> {
4545
const rundownsObserver = await RundownsObserver.createForPeripheralDevice(args.deviceId, async (rundownIds) => {
46-
logger.silly(`Creating new RundownContentObserver`)
46+
logger.silly(`Creating new RundownContentObserver`, rundownIds)
4747

4848
// TODO - can this be done cheaper?
4949
const cache = createReactiveContentCache(rundownIds)
@@ -181,10 +181,19 @@ function regenerateForRundown(cache: ReadonlyDeep<ContentCache>, rundownId: Rund
181181
_id: rundownId,
182182
externalId: rundown.externalId,
183183

184+
active: 'inactive',
185+
184186
segments: [],
185187
}
186188

187-
const playlist = cache.Playlists.findOne(rundown.playlistId)
189+
const playlist = cache.Playlists.findOne({
190+
_id: rundown.playlistId,
191+
activationId: { $exists: true },
192+
})
193+
194+
if (playlist) {
195+
newDoc.active = playlist.rehearsal ? 'rehearsal' : 'active'
196+
}
188197

189198
const nrcsSegments = cache.NrcsIngestData.find({ rundownId, type: NrcsIngestCacheType.SEGMENT }).fetch()
190199
for (const nrcsSegment of nrcsSegments) {
@@ -203,7 +212,7 @@ function regenerateForRundown(cache: ReadonlyDeep<ContentCache>, rundownId: Rund
203212
const part = cache.Parts.findOne({ rundownId, _id: nrcsPart.partId })
204213
const partInstance = cache.PartInstances.findOne({
205214
rundownId,
206-
segmentId: nrcsPart.segmentId,
215+
// segmentId: nrcsPart.segmentId, // nocommit - these don't match for some reason
207216
'part._id': nrcsPart.partId,
208217
// nocommit TODO - prefer the currentPartInstance
209218
_id: {
@@ -218,10 +227,10 @@ function regenerateForRundown(cache: ReadonlyDeep<ContentCache>, rundownId: Rund
218227

219228
if (isCurrentPartInstance) {
220229
// If the current, it is playing
221-
playbackStatus = IngestPartPlaybackStatus.PLAYING
230+
playbackStatus = IngestPartPlaybackStatus.PLAY
222231
} else {
223232
// If not the current, but has been played, it is stopped
224-
playbackStatus = IngestPartPlaybackStatus.STOPPED
233+
playbackStatus = IngestPartPlaybackStatus.STOP
225234
}
226235
}
227236

@@ -249,13 +258,7 @@ meteorCustomPublish(
249258
async function (pub, deviceId: PeripheralDeviceId, token: string | undefined) {
250259
check(deviceId, String)
251260

252-
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, token, this)
253-
254-
const studioId = peripheralDevice.studioId
255-
if (!studioId) {
256-
logger.warn(`Pub.packageManagerPackageContainers: device "${peripheralDevice._id}" has no studioId`)
257-
return this.ready()
258-
}
261+
await checkAccessAndGetPeripheralDevice(deviceId, token, this)
259262

260263
await setUpCollectionOptimizedObserver<
261264
IngestRundownStatus,

meteor/server/publications/ingestStatus/reactiveContentCache.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import type { RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids'
99
import type { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
1010
import type { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
1111

12-
export type PlaylistFields = '_id' | 'currentPartInfo' | 'nextPartInfo'
12+
export type PlaylistFields = '_id' | 'activationId' | 'rehearsal' | 'currentPartInfo' | 'nextPartInfo'
1313
export const playlistFieldSpecifier = literal<MongoFieldSpecifierOnesStrict<Pick<DBRundownPlaylist, PlaylistFields>>>({
1414
_id: 1,
15+
activationId: 1,
16+
rehearsal: 1,
1517
currentPartInfo: 1,
1618
nextPartInfo: 1,
1719
})

meteor/server/publications/ingestStatus/rundownContentObserver.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
rundownFieldSpecifier,
1010
// segmentFieldSpecifier,
1111
} from './reactiveContentCache'
12-
import { PartInstances, Parts, RundownPlaylists, Rundowns } from '../../collections'
12+
import { NrcsIngestDataCache, PartInstances, Parts, RundownPlaylists, Rundowns } from '../../collections'
1313
import { waitForAllObserversReady } from '../lib/lib'
1414
import _ from 'underscore'
1515
import { ReactiveMongoObserverGroup, ReactiveMongoObserverGroupHandle } from '../lib/observerGroup'
@@ -47,10 +47,10 @@ export class RundownContentObserver {
4747
},
4848
{
4949
added: (doc) => {
50-
cache.Playlists.upsert(doc._id, { $set: doc as Partial<Document> })
50+
cache.Playlists.upsert(doc._id, doc)
5151
},
5252
changed: (doc) => {
53-
cache.Playlists.upsert(doc._id, { $set: doc as Partial<Document> })
53+
cache.Playlists.upsert(doc._id, doc)
5454
},
5555
removed: (doc) => {
5656
cache.Playlists.remove(doc._id)
@@ -98,10 +98,22 @@ export class RundownContentObserver {
9898
}
9999
),
100100
PartInstances.observeChanges(
101-
{ rundownId: { $in: rundownIds }, reset: { $ne: true }, orphaned: { $exists: false } },
101+
{
102+
rundownId: { $in: rundownIds },
103+
reset: { $ne: true },
104+
orphaned: { $exists: false },
105+
},
102106
cache.PartInstances.link(),
103107
{ fields: partInstanceFieldSpecifier }
104108
),
109+
NrcsIngestDataCache.observeChanges(
110+
{
111+
rundownId: {
112+
$in: rundownIds,
113+
},
114+
},
115+
cache.NrcsIngestData.link()
116+
),
105117

106118
observer.#playlistIdObserver,
107119
])

packages/job-worker/src/playout/activePlaylistActions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ export async function deactivateRundownPlaylistInner(
145145
let rundown: ReadonlyDeep<DBRundown> | undefined
146146
if (currentPartInstance) {
147147
rundown = playoutModel.getRundown(currentPartInstance.partInstance.rundownId)?.rundown
148-
149-
playoutModel.queueNotifyCurrentlyPlayingPartEvent(currentPartInstance.partInstance.rundownId, null)
150148
} else if (nextPartInstance) {
151149
rundown = playoutModel.getRundown(nextPartInstance.partInstance.rundownId)?.rundown
152150
}

packages/job-worker/src/playout/model/PlayoutModel.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,6 @@ export interface PlayoutModel extends PlayoutModelReadonly, StudioPlayoutModelBa
263263
*/
264264
queuePartInstanceTimingEvent(partInstanceId: PartInstanceId): void
265265

266-
/**
267-
* Queue a `NotifyCurrentlyPlayingPart` operation to be performed upon completion of this Playout operation
268-
* @param rundownId The Rundown to report the notification to
269-
* @param partInstance The PartInstance the event is in relation to
270-
*/
271-
queueNotifyCurrentlyPlayingPartEvent(rundownId: RundownId, partInstance: PlayoutPartInstanceModel | null): void
272-
273266
/**
274267
* Remove all loaded PartInstances marked as `rehearsal` from this RundownPlaylist
275268
*/

packages/job-worker/src/playout/model/implementation/PlayoutModelImpl.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
273273
#timelineHasChanged = false
274274

275275
#pendingPartInstanceTimingEvents = new Set<PartInstanceId>()
276-
#pendingNotifyCurrentlyPlayingPartEvent = new Map<RundownId, string | null>()
277276

278277
get hackDeletedPartInstanceIds(): PartInstanceId[] {
279278
const result: PartInstanceId[] = []
@@ -520,13 +519,6 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
520519
this.#pendingPartInstanceTimingEvents.add(partInstanceId)
521520
}
522521

523-
queueNotifyCurrentlyPlayingPartEvent(rundownId: RundownId, partInstance: PlayoutPartInstanceModel | null): void {
524-
if (partInstance && partInstance.partInstance.part.shouldNotifyCurrentPlayingPart) {
525-
this.#pendingNotifyCurrentlyPlayingPartEvent.set(rundownId, partInstance.partInstance.part.externalId)
526-
} else if (!partInstance) {
527-
this.#pendingNotifyCurrentlyPlayingPartEvent.set(rundownId, null)
528-
}
529-
}
530522

531523
removeAllRehearsalPartInstances(): void {
532524
const partInstancesToRemove: PartInstanceId[] = []
@@ -689,20 +681,7 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
689681
}
690682
this.#pendingPartInstanceTimingEvents.clear()
691683

692-
for (const [rundownId, partExternalId] of this.#pendingNotifyCurrentlyPlayingPartEvent) {
693-
// This is low-prio, defer so that it's executed well after publications has been updated,
694-
// so that the playout gateway has had the chance to learn about the timeline changes
695-
this.context
696-
.queueEventJob(EventsJobs.NotifyCurrentlyPlayingPart, {
697-
rundownId: rundownId,
698-
isRehearsal: !!this.playlist.rehearsal,
699-
partExternalId: partExternalId,
700-
})
701-
.catch((e) => {
702-
logger.warn(`Failed to queue NotifyCurrentlyPlayingPart job: ${stringifyError(e)}`)
703-
})
704-
}
705-
this.#pendingNotifyCurrentlyPlayingPartEvent.clear()
684+
706685

707686
if (span) span.end()
708687
}

packages/job-worker/src/playout/take.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,6 @@ export async function afterTake(
547547

548548
await updateTimeline(context, playoutModel)
549549

550-
playoutModel.queueNotifyCurrentlyPlayingPartEvent(takePartInstance.partInstance.rundownId, takePartInstance)
551-
552550
if (span) span.end()
553551
}
554552

0 commit comments

Comments
 (0)