Skip to content

Commit 799ab71

Browse files
authored
Merge pull request Sofie-Automation#1295 from bbc/upstream/playlist-notes
2 parents d2aa933 + c5b833d commit 799ab71

File tree

13 files changed

+151
-64
lines changed

13 files changed

+151
-64
lines changed

meteor/server/publications/lib/quickLoop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { MarkerPosition, compareMarkerPositions } from '@sofie-automation/coreli
99
import { ProtectedString, unprotectString } from '@sofie-automation/corelib/dist/protectedString'
1010
import { DEFAULT_FALLBACK_PART_DURATION } from '@sofie-automation/shared-lib/dist/core/constants'
1111
import { getCurrentTime } from '../../lib/lib'
12-
import { generateTranslation } from '@sofie-automation/meteor-lib/dist/lib'
12+
import { generateTranslation } from '@sofie-automation/corelib/dist/lib'
1313
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
1414
import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartInstance'
1515
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'

packages/corelib/src/dataModel/Notes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export interface GenericNote extends INoteBase {
2424
name: string
2525
}
2626
}
27+
export interface RundownPlaylistNote extends INoteBase {
28+
origin: {
29+
name: string
30+
}
31+
}
2732
export interface RundownNote extends INoteBase {
2833
origin: {
2934
name: string

packages/corelib/src/dataModel/RundownPlaylist.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
StudioId,
1111
RundownId,
1212
} from './Ids'
13+
import { RundownPlaylistNote } from './Notes'
1314

1415
/** Details of an ab-session requested by the blueprints in onTimelineGenerate */
1516
export interface ABSessionInfo {
@@ -152,6 +153,9 @@ export interface DBRundownPlaylist {
152153
*/
153154
queuedSegmentId?: SegmentId
154155

156+
/** Holds notes (warnings / errors) thrown by the blueprints during creation */
157+
notes?: Array<RundownPlaylistNote>
158+
155159
quickLoop?: QuickLoopProps
156160

157161
/** Actual time of playback starting */

packages/corelib/src/lib.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Timecode } from 'timecode'
77
import { iterateDeeply, iterateDeeplyEnum, Time } from '@sofie-automation/blueprints-integration'
88
import { IStudioSettings } from './dataModel/Studio'
99
import { customAlphabet as createNanoid } from 'nanoid'
10+
import type { ITranslatableMessage } from './TranslatableMessage'
1011

1112
/**
1213
* Limited character set to use for id generation
@@ -455,3 +456,16 @@ export function stringifyObjects(objs: unknown): string {
455456
return objs + ''
456457
}
457458
}
459+
460+
/** Generate the translation for a string, to be applied later when it gets rendered */
461+
export function generateTranslation(
462+
key: string,
463+
args?: { [k: string]: any },
464+
namespaces?: string[]
465+
): ITranslatableMessage {
466+
return {
467+
key,
468+
args,
469+
namespaces,
470+
}
471+
}

packages/job-worker/src/blueprints/context/StudioUserContext.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ import { ReadonlyDeep } from 'type-fest'
33
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
44
import { ProcessedStudioConfig } from '../config'
55
import { INoteBase } from '@sofie-automation/corelib/dist/dataModel/Notes'
6-
import { UserContextInfo } from './CommonContext'
6+
import { ContextInfo } from './CommonContext'
77
import { StudioContext } from './StudioContext'
88

99
export class StudioUserContext extends StudioContext implements IStudioUserContext {
1010
public readonly notes: INoteBase[] = []
11-
private readonly tempSendNotesIntoBlackHole: boolean
1211

1312
constructor(
14-
contextInfo: UserContextInfo,
13+
contextInfo: ContextInfo,
1514
studio: ReadonlyDeep<DBStudio>,
1615
studioBlueprintConfig: ProcessedStudioConfig
1716
) {
1817
super(contextInfo, studio, studioBlueprintConfig)
19-
this.tempSendNotesIntoBlackHole = contextInfo.tempSendUserNotesIntoBlackHole ?? false
2018
}
2119

2220
notifyUserError(message: string, params?: { [key: string]: any }): void {
@@ -30,16 +28,12 @@ export class StudioUserContext extends StudioContext implements IStudioUserConte
3028
this.addNote(NoteSeverity.INFO, message, params)
3129
}
3230
private addNote(type: NoteSeverity, message: string, params?: { [key: string]: any }) {
33-
if (this.tempSendNotesIntoBlackHole) {
34-
this.logNote(`UserNotes: "${message}", ${JSON.stringify(params)}`, type)
35-
} else {
36-
this.notes.push({
37-
type: type,
38-
message: {
39-
key: message,
40-
args: params,
41-
},
42-
})
43-
}
31+
this.notes.push({
32+
type: type,
33+
message: {
34+
key: message,
35+
args: params,
36+
},
37+
})
4438
}
4539
}

packages/job-worker/src/ingest/__tests__/selectShowStyleVariant.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ describe('selectShowStyleVariant', () => {
2222
{
2323
name: 'test',
2424
identifier: 'test',
25-
tempSendUserNotesIntoBlackHole: true,
2625
},
2726
context.studio,
2827
context.getStudioBlueprintConfig()

packages/job-worker/src/ingest/generationRundown.ts

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ export async function updateRundownFromIngestData(
5858
{
5959
name: 'selectShowStyleVariant',
6060
identifier: `studioId=${context.studio._id},rundownId=${ingestModel.rundownId},ingestRundownId=${ingestModel.rundownExternalId}`,
61-
tempSendUserNotesIntoBlackHole: true,
6261
},
6362
context.studio,
6463
context.getStudioBlueprintConfig()
6564
)
66-
// TODO-CONTEXT save any user notes from selectShowStyleContext
65+
6766
const showStyle = await selectShowStyleVariant(
6867
context,
6968
selectShowStyleContext,
@@ -80,6 +79,14 @@ export async function updateRundownFromIngestData(
8079
const showStyleBlueprint = await context.getShowStyleBlueprint(showStyle.base._id)
8180
const allRundownWatchedPackages = await pAllRundownWatchedPackages
8281

82+
const extraRundownNotes: RundownNote[] = selectShowStyleContext.notes.map((note) => ({
83+
type: note.type,
84+
message: wrapTranslatableMessageFromBlueprints(note.message, [showStyleBlueprint.blueprintId]),
85+
origin: {
86+
name: 'selectShowStyleVariant',
87+
},
88+
}))
89+
8390
// Call blueprints, get rundown
8491
const dbRundown = await regenerateRundownAndBaselineFromIngestData(
8592
context,
@@ -88,7 +95,8 @@ export async function updateRundownFromIngestData(
8895
rundownSource,
8996
showStyle,
9097
showStyleBlueprint,
91-
allRundownWatchedPackages
98+
allRundownWatchedPackages,
99+
extraRundownNotes
92100
)
93101
if (!dbRundown) {
94102
// We got no rundown, abort:
@@ -147,13 +155,11 @@ export async function updateRundownMetadataFromIngestData(
147155
{
148156
name: 'selectShowStyleVariant',
149157
identifier: `studioId=${context.studio._id},rundownId=${ingestModel.rundownId},ingestRundownId=${ingestModel.rundownExternalId}`,
150-
tempSendUserNotesIntoBlackHole: true,
151158
},
152159
context.studio,
153160
context.getStudioBlueprintConfig()
154161
)
155162

156-
// TODO-CONTEXT save any user notes from selectShowStyleContext
157163
const showStyle = await selectShowStyleVariant(
158164
context,
159165
selectShowStyleContext,
@@ -170,6 +176,14 @@ export async function updateRundownMetadataFromIngestData(
170176
const showStyleBlueprint = await context.getShowStyleBlueprint(showStyle.base._id)
171177
const allRundownWatchedPackages = await pAllRundownWatchedPackages
172178

179+
const extraRundownNotes: RundownNote[] = selectShowStyleContext.notes.map((note) => ({
180+
type: note.type,
181+
message: wrapTranslatableMessageFromBlueprints(note.message, [showStyleBlueprint.blueprintId]),
182+
origin: {
183+
name: 'selectShowStyleVariant',
184+
},
185+
}))
186+
173187
// Call blueprints, get rundown
174188
const dbRundown = await regenerateRundownAndBaselineFromIngestData(
175189
context,
@@ -178,7 +192,8 @@ export async function updateRundownMetadataFromIngestData(
178192
rundownSource,
179193
showStyle,
180194
showStyleBlueprint,
181-
allRundownWatchedPackages
195+
allRundownWatchedPackages,
196+
extraRundownNotes
182197
)
183198
if (!dbRundown) {
184199
// We got no rundown, abort:
@@ -225,6 +240,7 @@ export async function updateRundownMetadataFromIngestData(
225240
* @param showStyle ShowStyle to regenerate for
226241
* @param showStyleBlueprint ShowStyle Blueprint to regenerate with
227242
* @param allRundownWatchedPackages WatchedPackagesHelper for all packages belonging to the rundown
243+
* @param extraRundownNotes Additional notes to add to the Rundown, produced earlier in the ingest process
228244
* @returns Generated documents or null if Blueprints reject the Rundown
229245
*/
230246
export async function regenerateRundownAndBaselineFromIngestData(
@@ -234,7 +250,8 @@ export async function regenerateRundownAndBaselineFromIngestData(
234250
rundownSource: RundownSource,
235251
showStyle: SelectedShowStyleVariant,
236252
showStyleBlueprint: ReadonlyDeep<WrappedShowStyleBlueprint>,
237-
allRundownWatchedPackages: WatchedPackagesHelper
253+
allRundownWatchedPackages: WatchedPackagesHelper,
254+
extraRundownNotes: RundownNote[]
238255
): Promise<ReadonlyDeep<DBRundown> | null> {
239256
const rundownBaselinePackages = allRundownWatchedPackages.filter(
240257
context,
@@ -297,15 +314,17 @@ export async function regenerateRundownAndBaselineFromIngestData(
297314
}
298315

299316
// Ensure the ids in the notes are clean
300-
const rundownNotes = blueprintContext.notes.map((note) =>
301-
literal<RundownNote>({
302-
type: note.type,
303-
message: wrapTranslatableMessageFromBlueprints(note.message, translationNamespaces),
304-
origin: {
305-
name: `${showStyle.base.name}-${showStyle.variant.name}`,
306-
},
307-
})
308-
)
317+
const rundownNotes = blueprintContext.notes
318+
.map((note) =>
319+
literal<RundownNote>({
320+
type: note.type,
321+
message: wrapTranslatableMessageFromBlueprints(note.message, translationNamespaces),
322+
origin: {
323+
name: `${showStyle.base.name}-${showStyle.variant.name}`,
324+
},
325+
})
326+
)
327+
.concat(extraRundownNotes)
309328

310329
ingestModel.setRundownData(
311330
rundownRes.rundown,

packages/job-worker/src/ingest/mosDevice/__tests__/__snapshots__/mosIngest.test.ts.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ exports[`Test recieved mos ingest payloads mosRoCreate 1`] = `
99
"modified": 0,
1010
"name": "All effect1 into clip combinations",
1111
"nextPartInfo": null,
12+
"notes": [],
1213
"organizationId": null,
1314
"previousPartInfo": null,
1415
"rundownIdsInOrder": [
@@ -306,6 +307,7 @@ exports[`Test recieved mos ingest payloads mosRoCreate: replace existing 1`] = `
306307
"modified": 0,
307308
"name": "All effect1 into clip combinations",
308309
"nextPartInfo": null,
310+
"notes": [],
309311
"organizationId": null,
310312
"previousPartInfo": null,
311313
"rundownIdsInOrder": [
@@ -594,6 +596,7 @@ exports[`Test recieved mos ingest payloads mosRoFullStory: Valid data 1`] = `
594596
"modified": 0,
595597
"name": "All effect1 into clip combinations",
596598
"nextPartInfo": null,
599+
"notes": [],
597600
"organizationId": null,
598601
"previousPartInfo": null,
599602
"rundownIdsInOrder": [
@@ -904,6 +907,7 @@ exports[`Test recieved mos ingest payloads mosRoReadyToAir: Update ro 1`] = `
904907
"modified": 0,
905908
"name": "All effect1 into clip combinations",
906909
"nextPartInfo": null,
910+
"notes": [],
907911
"organizationId": null,
908912
"previousPartInfo": null,
909913
"rundownIdsInOrder": [
@@ -1204,6 +1208,7 @@ exports[`Test recieved mos ingest payloads mosRoStatus: Update ro 1`] = `
12041208
"modified": 0,
12051209
"name": "All effect1 into clip combinations",
12061210
"nextPartInfo": null,
1211+
"notes": [],
12071212
"organizationId": null,
12081213
"previousPartInfo": null,
12091214
"rundownIdsInOrder": [
@@ -1502,6 +1507,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryDelete: Remove segment 1`]
15021507
"modified": 0,
15031508
"name": "All effect1 into clip combinations",
15041509
"nextPartInfo": null,
1510+
"notes": [],
15051511
"organizationId": null,
15061512
"previousPartInfo": null,
15071513
"rundownIdsInOrder": [
@@ -1766,6 +1772,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryInsert: Into segment 1`] =
17661772
"modified": 0,
17671773
"name": "All effect1 into clip combinations",
17681774
"nextPartInfo": null,
1775+
"notes": [],
17691776
"organizationId": null,
17701777
"previousPartInfo": null,
17711778
"rundownIdsInOrder": [
@@ -2077,6 +2084,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryInsert: New segment 1`] = `
20772084
"modified": 0,
20782085
"name": "All effect1 into clip combinations",
20792086
"nextPartInfo": null,
2087+
"notes": [],
20802088
"organizationId": null,
20812089
"previousPartInfo": null,
20822090
"rundownIdsInOrder": [
@@ -2397,6 +2405,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryMove: Move whole segment to
23972405
"modified": 0,
23982406
"name": "All effect1 into clip combinations",
23992407
"nextPartInfo": null,
2408+
"notes": [],
24002409
"organizationId": null,
24012410
"previousPartInfo": null,
24022411
"rundownIdsInOrder": [
@@ -2699,6 +2708,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryMove: Within segment 1`] =
26992708
"modified": 0,
27002709
"name": "All effect1 into clip combinations",
27012710
"nextPartInfo": null,
2711+
"notes": [],
27022712
"organizationId": null,
27032713
"previousPartInfo": null,
27042714
"rundownIdsInOrder": [
@@ -3001,6 +3011,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryReplace: Same segment 1`] =
30013011
"modified": 0,
30023012
"name": "All effect1 into clip combinations",
30033013
"nextPartInfo": null,
3014+
"notes": [],
30043015
"organizationId": null,
30053016
"previousPartInfo": null,
30063017
"rundownIdsInOrder": [
@@ -3302,6 +3313,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: Swap across segments
33023313
"modified": 0,
33033314
"name": "All effect1 into clip combinations",
33043315
"nextPartInfo": null,
3316+
"notes": [],
33053317
"organizationId": null,
33063318
"previousPartInfo": null,
33073319
"rundownIdsInOrder": [
@@ -3595,6 +3607,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: Swap across segments2
35953607
"modified": 0,
35963608
"name": "All effect1 into clip combinations",
35973609
"nextPartInfo": null,
3610+
"notes": [],
35983611
"organizationId": null,
35993612
"previousPartInfo": null,
36003613
"rundownIdsInOrder": [
@@ -3924,6 +3937,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: With first in same se
39243937
"modified": 0,
39253938
"name": "All effect1 into clip combinations",
39263939
"nextPartInfo": null,
3940+
"notes": [],
39273941
"organizationId": null,
39283942
"previousPartInfo": null,
39293943
"rundownIdsInOrder": [
@@ -4226,6 +4240,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: Within same segment 1
42264240
"modified": 0,
42274241
"name": "All effect1 into clip combinations",
42284242
"nextPartInfo": null,
4243+
"notes": [],
42294244
"organizationId": null,
42304245
"previousPartInfo": null,
42314246
"rundownIdsInOrder": [

0 commit comments

Comments
 (0)