File tree Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { addMigrationSteps } from './databaseMigration'
2
2
import { CURRENT_SYSTEM_VERSION } from './currentSystemVersion'
3
3
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'
5
5
import { PeripheralDeviceId , RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids'
6
6
7
7
/*
@@ -71,4 +71,33 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
71
71
}
72
72
} ,
73
73
} ,
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
+ } ,
74
103
] )
Original file line number Diff line number Diff line change @@ -12,10 +12,8 @@ import { RundownNote } from './Notes'
12
12
import { ReadonlyDeep } from 'type-fest'
13
13
14
14
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 */
16
16
DELETED = 'deleted' ,
17
- /** Rundown was restored from a snapshot and does not correspond with a rundown in the NRCS */
18
- FROM_SNAPSHOT = 'from-snapshot' ,
19
17
/** Rundown was unsynced by the user */
20
18
MANUAL = 'manual' ,
21
19
}
@@ -29,7 +27,6 @@ export interface RundownImportVersions {
29
27
core : string
30
28
}
31
29
32
- /** This is a very uncomplete mock-up of the Rundown object */
33
30
export interface Rundown {
34
31
_id : RundownId
35
32
/** ID of the organization that owns the rundown */
@@ -53,9 +50,10 @@ export interface Rundown {
53
50
/** Air-status, comes from NCS, examples: "READY" | "NOT READY" */
54
51
airStatus ?: string
55
52
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
+ */
59
57
orphaned ?: RundownOrphanedReason
60
58
61
59
/** Last sent storyStatus to ingestDevice (MOS) */
Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ export async function handleRestorePlaylistSnapshot(
163
163
164
164
for ( const rd of snapshot . rundowns ) {
165
165
if ( ! rd . orphaned ) {
166
- rd . orphaned = RundownOrphanedReason . FROM_SNAPSHOT
166
+ rd . orphaned = RundownOrphanedReason . MANUAL
167
167
}
168
168
169
169
rd . playlistId = playlistId
You can’t perform that action at this time.
0 commit comments