Skip to content

Commit 75adb3a

Browse files
committed
wip: rename property
1 parent 841ffde commit 75adb3a

File tree

11 files changed

+69
-21
lines changed

11 files changed

+69
-21
lines changed

meteor/server/migration/X_X_X.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addMigrationSteps } from './databaseMigration'
22
import { CURRENT_SYSTEM_VERSION } from './currentSystemVersion'
33
import { MongoInternals } from 'meteor/mongo'
4-
import { Studios } from '../collections'
4+
import { RundownPlaylists, Studios } from '../collections'
55
import { ExpectedPackages } from '../collections'
66
import * as PackagesPreR53 from '@sofie-automation/corelib/dist/dataModel/Old/ExpectedPackagesR52'
77
import {
@@ -195,4 +195,48 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
195195
}
196196
},
197197
},
198+
{
199+
id: `Rename previousPersistentState to privatePlayoutPersistentState`,
200+
canBeRunAutomatically: true,
201+
validate: async () => {
202+
const playlists = await RundownPlaylists.countDocuments({
203+
previousPersistentState: { $exists: true },
204+
privatePlayoutPersistentState: { $exists: false },
205+
})
206+
if (playlists > 0) {
207+
return 'One or more Playlists has previousPersistentState field that needs to be renamed to privatePlayoutPersistentState'
208+
}
209+
210+
return false
211+
},
212+
migrate: async () => {
213+
const playlists = await RundownPlaylists.findFetchAsync(
214+
{
215+
previousPersistentState: { $exists: true },
216+
privatePlayoutPersistentState: { $exists: false },
217+
},
218+
{
219+
projection: {
220+
_id: 1,
221+
// @ts-expect-error - This field is being renamed, so it won't exist on the type anymore
222+
previousPersistentState: 1,
223+
},
224+
}
225+
)
226+
227+
for (const playlist of playlists) {
228+
// @ts-expect-error - This field is being renamed, so it won't exist on the type anymore
229+
const previousPersistentState = playlist.previousPersistentState
230+
231+
await RundownPlaylists.mutableCollection.updateAsync(playlist._id, {
232+
$set: {
233+
privatePlayoutPersistentState: previousPersistentState,
234+
},
235+
$unset: {
236+
previousPersistentState: 1,
237+
},
238+
})
239+
}
240+
},
241+
},
198242
])

packages/corelib/src/dataModel/RundownPlaylist.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ export interface DBRundownPlaylist {
171171
* Persistent state belong to blueprint playout methods
172172
* This can be accessed and modified by the blueprints in various methods
173173
*/
174-
previousPersistentState?: TimelinePersistentState
174+
privatePlayoutPersistentState?: TimelinePersistentState
175175
/**
176176
* Persistent state belong to blueprint playout methods, but exposed to APIs such as the LSG
177177
* This can be accessed and modified by the blueprints in various methods, but is also exposed to APIs such as the LSG
178178
*/
179-
previousPublicPersistentState?: TimelinePersistentState
179+
publicPlayoutPersistentState?: TimelinePersistentState
180180

181181
/** AB playback sessions calculated in the last timeline genertaion */
182182
trackedAbSessions?: ABSessionInfo[]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ export async function executeActionInner(
242242

243243
try {
244244
const blueprintPersistentState = new PersistentPlayoutStateStore(
245-
playoutModel.playlist.previousPersistentState,
246-
playoutModel.playlist.previousPublicPersistentState
245+
playoutModel.playlist.privatePlayoutPersistentState,
246+
playoutModel.playlist.publicPlayoutPersistentState
247247
)
248248

249249
await blueprint.blueprint.executeAction(

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
661661
delete this.playlistImpl.startedPlayback
662662
delete this.playlistImpl.rundownsStartedPlayback
663663
delete this.playlistImpl.segmentsStartedPlayback
664-
delete this.playlistImpl.previousPersistentState
664+
delete this.playlistImpl.publicPlayoutPersistentState
665+
delete this.playlistImpl.privatePlayoutPersistentState
665666
delete this.playlistImpl.trackedAbSessions
666667
delete this.playlistImpl.queuedSegmentId
667668

@@ -765,12 +766,12 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
765766
}
766767

767768
setBlueprintPrivatePersistentState(persistentState: unknown | undefined): void {
768-
this.playlistImpl.previousPersistentState = persistentState
769+
this.playlistImpl.privatePlayoutPersistentState = persistentState
769770

770771
this.#playlistHasChanged = true
771772
}
772773
setBlueprintPublicPersistentState(persistentState: unknown | undefined): void {
773-
this.playlistImpl.previousPublicPersistentState = persistentState
774+
this.playlistImpl.publicPlayoutPersistentState = persistentState
774775

775776
this.#playlistHasChanged = true
776777
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ async function executeOnSetAsNextCallback(
230230

231231
try {
232232
const blueprintPersistentState = new PersistentPlayoutStateStore(
233-
playoutModel.playlist.previousPersistentState,
234-
playoutModel.playlist.previousPublicPersistentState
233+
playoutModel.playlist.privatePlayoutPersistentState,
234+
playoutModel.playlist.publicPlayoutPersistentState
235235
)
236236

237237
await blueprint.blueprint.onSetAsNext(onSetAsNextContext, blueprintPersistentState)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ async function executeOnTakeCallback(
343343
)
344344
try {
345345
const blueprintPersistentState = new PersistentPlayoutStateStore(
346-
playoutModel.playlist.previousPersistentState,
347-
playoutModel.playlist.previousPublicPersistentState
346+
playoutModel.playlist.privatePlayoutPersistentState,
347+
playoutModel.playlist.publicPlayoutPersistentState
348348
)
349349

350350
await blueprint.blueprint.onTake(onSetAsNextContext, blueprintPersistentState)
@@ -548,8 +548,8 @@ export function updatePartInstanceOnTake(
548548
takeRundown
549549
)
550550
const blueprintPersistentState = new PersistentPlayoutStateStore(
551-
playoutModel.playlist.previousPersistentState,
552-
playoutModel.playlist.previousPublicPersistentState
551+
playoutModel.playlist.privatePlayoutPersistentState,
552+
playoutModel.playlist.publicPlayoutPersistentState
553553
)
554554
previousPartEndState = blueprint.blueprint.getEndStateForPart(
555555
context2,

packages/job-worker/src/playout/timeline/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ async function getTimelineRundown(
435435

436436
if (blueprint.blueprint.onTimelineGenerate) {
437437
const blueprintPersistentState = new PersistentPlayoutStateStore(
438-
playoutModel.playlist.previousPersistentState,
439-
playoutModel.playlist.previousPublicPersistentState
438+
playoutModel.playlist.privatePlayoutPersistentState,
439+
playoutModel.playlist.publicPlayoutPersistentState
440440
)
441441

442442
const span = context.startSpan('blueprint.onTimelineGenerate')

packages/live-status-gateway/src/topics/activePlaylistTopic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const PLAYLIST_KEYS = [
4545
'name',
4646
'rundownIdsInOrder',
4747
'publicData',
48-
'previousPersistentState',
48+
'publicPlayoutPersistentState',
4949
'currentPartInfo',
5050
'nextPartInfo',
5151
'timing',
@@ -158,7 +158,7 @@ export class ActivePlaylistTopic extends WebSocketTopicBase implements WebSocket
158158
: null,
159159
quickLoop: this.transformQuickLoopStatus(),
160160
publicData: this._activePlaylist.publicData,
161-
playoutState: this._activePlaylist.previousPersistentState,
161+
playoutState: this._activePlaylist.publicPlayoutPersistentState,
162162
timing: {
163163
timingMode: translatePlaylistTimingType(this._activePlaylist.timing.type),
164164
startedPlayback: this._activePlaylist.startedPlayback,

packages/webui/src/client/ui/ClockView/DirectorScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ const getDirectorScreenReactive = (props: DirectorScreenProps): DirectorScreenTr
242242
fields: {
243243
lastIncorrectPartPlaybackReported: 0,
244244
modified: 0,
245-
previousPersistentState: 0,
245+
publicPlayoutPersistentState: 0,
246+
privatePlayoutPersistentState: 0,
246247
rundownRanksAreSetInSofie: 0,
247248
// Note: Do not exclude assignedAbSessions/trackedAbSessions so they stay reactive
248249
restoredFromSnapshotId: 0,

packages/webui/src/client/ui/ClockView/PresenterScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ export const getPresenterScreenReactive = (
184184
fields: {
185185
lastIncorrectPartPlaybackReported: 0,
186186
modified: 0,
187-
previousPersistentState: 0,
187+
publicPlayoutPersistentState: 0,
188+
privatePlayoutPersistentState: 0,
188189
rundownRanksAreSetInSofie: 0,
189190
trackedAbSessions: 0,
190191
restoredFromSnapshotId: 0,

0 commit comments

Comments
 (0)