Skip to content

Commit

Permalink
Merge pull request #1295 from bbc/upstream/playlist-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl authored Oct 29, 2024
2 parents d2aa933 + c5b833d commit 799ab71
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 64 deletions.
2 changes: 1 addition & 1 deletion meteor/server/publications/lib/quickLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MarkerPosition, compareMarkerPositions } from '@sofie-automation/coreli
import { ProtectedString, unprotectString } from '@sofie-automation/corelib/dist/protectedString'
import { DEFAULT_FALLBACK_PART_DURATION } from '@sofie-automation/shared-lib/dist/core/constants'
import { getCurrentTime } from '../../lib/lib'
import { generateTranslation } from '@sofie-automation/meteor-lib/dist/lib'
import { generateTranslation } from '@sofie-automation/corelib/dist/lib'
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartInstance'
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
Expand Down
5 changes: 5 additions & 0 deletions packages/corelib/src/dataModel/Notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export interface GenericNote extends INoteBase {
name: string
}
}
export interface RundownPlaylistNote extends INoteBase {
origin: {
name: string
}
}
export interface RundownNote extends INoteBase {
origin: {
name: string
Expand Down
4 changes: 4 additions & 0 deletions packages/corelib/src/dataModel/RundownPlaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
StudioId,
RundownId,
} from './Ids'
import { RundownPlaylistNote } from './Notes'

/** Details of an ab-session requested by the blueprints in onTimelineGenerate */
export interface ABSessionInfo {
Expand Down Expand Up @@ -152,6 +153,9 @@ export interface DBRundownPlaylist {
*/
queuedSegmentId?: SegmentId

/** Holds notes (warnings / errors) thrown by the blueprints during creation */
notes?: Array<RundownPlaylistNote>

quickLoop?: QuickLoopProps

/** Actual time of playback starting */
Expand Down
14 changes: 14 additions & 0 deletions packages/corelib/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Timecode } from 'timecode'
import { iterateDeeply, iterateDeeplyEnum, Time } from '@sofie-automation/blueprints-integration'
import { IStudioSettings } from './dataModel/Studio'
import { customAlphabet as createNanoid } from 'nanoid'
import type { ITranslatableMessage } from './TranslatableMessage'

/**
* Limited character set to use for id generation
Expand Down Expand Up @@ -455,3 +456,16 @@ export function stringifyObjects(objs: unknown): string {
return objs + ''
}
}

/** Generate the translation for a string, to be applied later when it gets rendered */
export function generateTranslation(
key: string,
args?: { [k: string]: any },
namespaces?: string[]
): ITranslatableMessage {
return {
key,
args,
namespaces,
}
}
24 changes: 9 additions & 15 deletions packages/job-worker/src/blueprints/context/StudioUserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import { ReadonlyDeep } from 'type-fest'
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
import { ProcessedStudioConfig } from '../config'
import { INoteBase } from '@sofie-automation/corelib/dist/dataModel/Notes'
import { UserContextInfo } from './CommonContext'
import { ContextInfo } from './CommonContext'
import { StudioContext } from './StudioContext'

export class StudioUserContext extends StudioContext implements IStudioUserContext {
public readonly notes: INoteBase[] = []
private readonly tempSendNotesIntoBlackHole: boolean

constructor(
contextInfo: UserContextInfo,
contextInfo: ContextInfo,
studio: ReadonlyDeep<DBStudio>,
studioBlueprintConfig: ProcessedStudioConfig
) {
super(contextInfo, studio, studioBlueprintConfig)
this.tempSendNotesIntoBlackHole = contextInfo.tempSendUserNotesIntoBlackHole ?? false
}

notifyUserError(message: string, params?: { [key: string]: any }): void {
Expand All @@ -30,16 +28,12 @@ export class StudioUserContext extends StudioContext implements IStudioUserConte
this.addNote(NoteSeverity.INFO, message, params)
}
private addNote(type: NoteSeverity, message: string, params?: { [key: string]: any }) {
if (this.tempSendNotesIntoBlackHole) {
this.logNote(`UserNotes: "${message}", ${JSON.stringify(params)}`, type)
} else {
this.notes.push({
type: type,
message: {
key: message,
args: params,
},
})
}
this.notes.push({
type: type,
message: {
key: message,
args: params,
},
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('selectShowStyleVariant', () => {
{
name: 'test',
identifier: 'test',
tempSendUserNotesIntoBlackHole: true,
},
context.studio,
context.getStudioBlueprintConfig()
Expand Down
51 changes: 35 additions & 16 deletions packages/job-worker/src/ingest/generationRundown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ export async function updateRundownFromIngestData(
{
name: 'selectShowStyleVariant',
identifier: `studioId=${context.studio._id},rundownId=${ingestModel.rundownId},ingestRundownId=${ingestModel.rundownExternalId}`,
tempSendUserNotesIntoBlackHole: true,
},
context.studio,
context.getStudioBlueprintConfig()
)
// TODO-CONTEXT save any user notes from selectShowStyleContext

const showStyle = await selectShowStyleVariant(
context,
selectShowStyleContext,
Expand All @@ -80,6 +79,14 @@ export async function updateRundownFromIngestData(
const showStyleBlueprint = await context.getShowStyleBlueprint(showStyle.base._id)
const allRundownWatchedPackages = await pAllRundownWatchedPackages

const extraRundownNotes: RundownNote[] = selectShowStyleContext.notes.map((note) => ({
type: note.type,
message: wrapTranslatableMessageFromBlueprints(note.message, [showStyleBlueprint.blueprintId]),
origin: {
name: 'selectShowStyleVariant',
},
}))

// Call blueprints, get rundown
const dbRundown = await regenerateRundownAndBaselineFromIngestData(
context,
Expand All @@ -88,7 +95,8 @@ export async function updateRundownFromIngestData(
rundownSource,
showStyle,
showStyleBlueprint,
allRundownWatchedPackages
allRundownWatchedPackages,
extraRundownNotes
)
if (!dbRundown) {
// We got no rundown, abort:
Expand Down Expand Up @@ -147,13 +155,11 @@ export async function updateRundownMetadataFromIngestData(
{
name: 'selectShowStyleVariant',
identifier: `studioId=${context.studio._id},rundownId=${ingestModel.rundownId},ingestRundownId=${ingestModel.rundownExternalId}`,
tempSendUserNotesIntoBlackHole: true,
},
context.studio,
context.getStudioBlueprintConfig()
)

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

const extraRundownNotes: RundownNote[] = selectShowStyleContext.notes.map((note) => ({
type: note.type,
message: wrapTranslatableMessageFromBlueprints(note.message, [showStyleBlueprint.blueprintId]),
origin: {
name: 'selectShowStyleVariant',
},
}))

// Call blueprints, get rundown
const dbRundown = await regenerateRundownAndBaselineFromIngestData(
context,
Expand All @@ -178,7 +192,8 @@ export async function updateRundownMetadataFromIngestData(
rundownSource,
showStyle,
showStyleBlueprint,
allRundownWatchedPackages
allRundownWatchedPackages,
extraRundownNotes
)
if (!dbRundown) {
// We got no rundown, abort:
Expand Down Expand Up @@ -225,6 +240,7 @@ export async function updateRundownMetadataFromIngestData(
* @param showStyle ShowStyle to regenerate for
* @param showStyleBlueprint ShowStyle Blueprint to regenerate with
* @param allRundownWatchedPackages WatchedPackagesHelper for all packages belonging to the rundown
* @param extraRundownNotes Additional notes to add to the Rundown, produced earlier in the ingest process
* @returns Generated documents or null if Blueprints reject the Rundown
*/
export async function regenerateRundownAndBaselineFromIngestData(
Expand All @@ -234,7 +250,8 @@ export async function regenerateRundownAndBaselineFromIngestData(
rundownSource: RundownSource,
showStyle: SelectedShowStyleVariant,
showStyleBlueprint: ReadonlyDeep<WrappedShowStyleBlueprint>,
allRundownWatchedPackages: WatchedPackagesHelper
allRundownWatchedPackages: WatchedPackagesHelper,
extraRundownNotes: RundownNote[]
): Promise<ReadonlyDeep<DBRundown> | null> {
const rundownBaselinePackages = allRundownWatchedPackages.filter(
context,
Expand Down Expand Up @@ -297,15 +314,17 @@ export async function regenerateRundownAndBaselineFromIngestData(
}

// Ensure the ids in the notes are clean
const rundownNotes = blueprintContext.notes.map((note) =>
literal<RundownNote>({
type: note.type,
message: wrapTranslatableMessageFromBlueprints(note.message, translationNamespaces),
origin: {
name: `${showStyle.base.name}-${showStyle.variant.name}`,
},
})
)
const rundownNotes = blueprintContext.notes
.map((note) =>
literal<RundownNote>({
type: note.type,
message: wrapTranslatableMessageFromBlueprints(note.message, translationNamespaces),
origin: {
name: `${showStyle.base.name}-${showStyle.variant.name}`,
},
})
)
.concat(extraRundownNotes)

ingestModel.setRundownData(
rundownRes.rundown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`Test recieved mos ingest payloads mosRoCreate 1`] = `
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -306,6 +307,7 @@ exports[`Test recieved mos ingest payloads mosRoCreate: replace existing 1`] = `
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -594,6 +596,7 @@ exports[`Test recieved mos ingest payloads mosRoFullStory: Valid data 1`] = `
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -904,6 +907,7 @@ exports[`Test recieved mos ingest payloads mosRoReadyToAir: Update ro 1`] = `
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -1204,6 +1208,7 @@ exports[`Test recieved mos ingest payloads mosRoStatus: Update ro 1`] = `
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -1502,6 +1507,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryDelete: Remove segment 1`]
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -1766,6 +1772,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryInsert: Into segment 1`] =
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -2077,6 +2084,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryInsert: New segment 1`] = `
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -2397,6 +2405,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryMove: Move whole segment to
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -2699,6 +2708,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryMove: Within segment 1`] =
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -3001,6 +3011,7 @@ exports[`Test recieved mos ingest payloads mosRoStoryReplace: Same segment 1`] =
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -3302,6 +3313,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: Swap across segments
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -3595,6 +3607,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: Swap across segments2
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -3924,6 +3937,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: With first in same se
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down Expand Up @@ -4226,6 +4240,7 @@ exports[`Test recieved mos ingest payloads mosRoStorySwap: Within same segment 1
"modified": 0,
"name": "All effect1 into clip combinations",
"nextPartInfo": null,
"notes": [],
"organizationId": null,
"previousPartInfo": null,
"rundownIdsInOrder": [
Expand Down
Loading

0 comments on commit 799ab71

Please sign in to comment.