Skip to content

Commit cf9fa15

Browse files
authored
fix: refactor Rundown orphaned property SOFIE-2963 #1210 (#1217)
fix: refactor Rundown orphaned property SOFIE-2963 #1210
1 parent 1de77fc commit cf9fa15

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

meteor/server/migration/X_X_X.ts

Lines changed: 30 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 { Rundowns } from '../collections'
4-
import { RundownSource } from '@sofie-automation/corelib/dist/dataModel/Rundown'
4+
import { RundownOrphanedReason, RundownSource } from '@sofie-automation/corelib/dist/dataModel/Rundown'
55
import { PeripheralDeviceId, RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids'
66

77
/*
@@ -71,4 +71,33 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
7171
}
7272
},
7373
},
74+
{
75+
id: `Rundowns remove orphaned FROM_SNAPSHOT`,
76+
canBeRunAutomatically: true,
77+
validate: async () => {
78+
const objects = await Rundowns.findFetchAsync({
79+
orphaned: 'from-snapshot' as any,
80+
})
81+
82+
if (objects.length > 0) {
83+
return `object needs to be updated`
84+
}
85+
return false
86+
},
87+
migrate: async () => {
88+
await Rundowns.mutableCollection.updateAsync(
89+
{
90+
orphaned: 'from-snapshot' as any,
91+
},
92+
{
93+
$set: {
94+
orphaned: RundownOrphanedReason.DELETED,
95+
},
96+
},
97+
{
98+
multi: true,
99+
}
100+
)
101+
},
102+
},
74103
])

packages/corelib/src/dataModel/Rundown.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import { RundownNote } from './Notes'
1212
import { ReadonlyDeep } from 'type-fest'
1313

1414
export enum RundownOrphanedReason {
15-
/** Rundown is deleted from the NRCS but we still need it */
15+
/** Rundown is deleted from the source but we still need it */
1616
DELETED = 'deleted',
17-
/** Rundown was restored from a snapshot and does not correspond with a rundown in the NRCS */
18-
FROM_SNAPSHOT = 'from-snapshot',
1917
/** Rundown was unsynced by the user */
2018
MANUAL = 'manual',
2119
}
@@ -29,7 +27,6 @@ export interface RundownImportVersions {
2927
core: string
3028
}
3129

32-
/** This is a very uncomplete mock-up of the Rundown object */
3330
export interface Rundown {
3431
_id: RundownId
3532
/** ID of the organization that owns the rundown */
@@ -53,9 +50,10 @@ export interface Rundown {
5350
/** Air-status, comes from NCS, examples: "READY" | "NOT READY" */
5451
airStatus?: string
5552

56-
// There should be something like a Owner user here somewhere?
57-
58-
/** Is the rundown in an unsynced (has been unpublished from ENPS) state? */
53+
/**
54+
* Is the rundown in an unsynced state?
55+
* This can be because the rundown was deleted from the source, or because the user manually unsynced it
56+
*/
5957
orphaned?: RundownOrphanedReason
6058

6159
/** Last sent storyStatus to ingestDevice (MOS) */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export async function handleRestorePlaylistSnapshot(
163163

164164
for (const rd of snapshot.rundowns) {
165165
if (!rd.orphaned) {
166-
rd.orphaned = RundownOrphanedReason.FROM_SNAPSHOT
166+
rd.orphaned = RundownOrphanedReason.MANUAL
167167
}
168168

169169
rd.playlistId = playlistId

0 commit comments

Comments
 (0)