@@ -91,38 +91,46 @@ async function restartCasparCG(systemSettings: ICoreSystemSettings | undefined,
91
91
let shouldRetryAttempt = false
92
92
const ps : Array < Promise < any > > = [ ]
93
93
94
- const [ casparcgAndParentDevices , activePlaylists ] = await Promise . all ( [
95
- PeripheralDevices . findFetchAsync (
96
- {
97
- type : PeripheralDeviceType . PLAYOUT ,
98
- subType : { $in : [ PERIPHERAL_SUBTYPE_PROCESS , TSR . DeviceType . CASPARCG ] } ,
94
+ const casparcgAndParentDevices = ( await PeripheralDevices . findFetchAsync (
95
+ {
96
+ type : PeripheralDeviceType . PLAYOUT ,
97
+ subType : { $in : [ PERIPHERAL_SUBTYPE_PROCESS , TSR . DeviceType . CASPARCG ] } ,
98
+ } ,
99
+ {
100
+ projection : {
101
+ _id : 1 ,
102
+ subType : 1 ,
103
+ parentDeviceId : 1 ,
104
+ lastSeen : 1 ,
105
+ studioAndConfigId : 1 ,
99
106
} ,
100
- {
101
- projection : {
102
- _id : 1 ,
103
- subType : 1 ,
104
- parentDeviceId : 1 ,
105
- lastSeen : 1 ,
106
- studioAndConfigId : 1 ,
107
- } ,
108
- }
109
- ) as Promise <
110
- Array < Pick < PeripheralDevice , '_id' | 'subType' | 'parentDeviceId' | 'lastSeen' | 'studioAndConfigId' > >
111
- > ,
112
- RundownPlaylists . findFetchAsync (
113
- {
114
- activationId : {
115
- $exists : true ,
116
- } ,
107
+ }
108
+ ) ) as Array < Pick < PeripheralDevice , '_id' | 'subType' | 'parentDeviceId' | 'lastSeen' | 'studioAndConfigId' > >
109
+
110
+ const relevantStudioIds = Array . from (
111
+ new Set (
112
+ casparcgAndParentDevices
113
+ . map ( ( device ) => device . studioAndConfigId ?. studioId )
114
+ . filter ( ( id ) => id !== undefined )
115
+ )
116
+ )
117
+
118
+ const activePlaylists = ( await RundownPlaylists . findFetchAsync (
119
+ {
120
+ activationId : {
121
+ $exists : true ,
117
122
} ,
118
- {
119
- projection : {
120
- _id : 1 ,
121
- studioId : 1 ,
122
- } ,
123
- }
124
- ) as Promise < Array < Pick < DBRundownPlaylist , '_id' | 'studioId' > > > ,
125
- ] )
123
+ studioId : {
124
+ $in : relevantStudioIds ,
125
+ } ,
126
+ } ,
127
+ {
128
+ projection : {
129
+ _id : 1 ,
130
+ studioId : 1 ,
131
+ } ,
132
+ }
133
+ ) ) as Array < Pick < DBRundownPlaylist , '_id' | 'studioId' > >
126
134
127
135
const deviceMap = normalizeArrayToMap ( casparcgAndParentDevices , '_id' )
128
136
0 commit comments