Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: document publications and remove mongo queries from parameters SOFIE-1183 #1062

Merged
merged 30 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
55f544c
wip: simplify some publications
Julusian Oct 30, 2023
c4fdd0d
wip: simplify some publications
Julusian Oct 30, 2023
83fac0e
wip: simplify some publications
Julusian Oct 30, 2023
4032378
wip: refactor pieceInstancesSimple
Julusian Oct 30, 2023
adb06d2
chore: renmove some unused publications
Julusian Oct 30, 2023
f1a026c
chore: remove some unnecessary publication filters
Julusian Oct 30, 2023
a808241
wip
Julusian Oct 30, 2023
695dd41
wip: segments
Julusian Oct 30, 2023
8ee960c
wip: showStyleBase
Julusian Oct 30, 2023
f1161e8
showStyleVariants
Julusian Oct 30, 2023
0de1ed1
expectedPackages
Julusian Oct 30, 2023
cc75c42
peripheralDevices
Julusian Oct 30, 2023
23dd59d
studios
Julusian Oct 30, 2023
7700087
wip: remove unused
Julusian Oct 30, 2023
86dda22
usersInOrganization
Julusian Oct 30, 2023
0e9f882
mediaWorkFlows
Julusian Oct 30, 2023
c75722b
blueprints
Julusian Oct 30, 2023
6b8a17e
pieces
Julusian Oct 30, 2023
01680a8
rundownPlaylists
Julusian Oct 30, 2023
12365ba
pieceInstances
Julusian Oct 30, 2023
fe2f552
rundownLayouts
Julusian Oct 30, 2023
703faaf
triggeredActions
Julusian Oct 30, 2023
3c652f4
translationsBundles
Julusian Oct 30, 2023
83813be
misc
Julusian Oct 30, 2023
4bd8dc4
bucketAdlibs
Julusian Oct 30, 2023
cdb028c
partInstancesSimple
Julusian Oct 31, 2023
c53749b
chore: doc comment for each publication
Julusian Oct 31, 2023
e2523c3
chore: fix test
Julusian Oct 31, 2023
2ab1fae
chore: review comments
Julusian Nov 17, 2023
fc5eed2
Merge branch 'release51' into feat/improve-publications
Julusian Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 7 additions & 25 deletions meteor/client/lib/triggers/TriggersHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,13 @@ function useSubscriptions(
showStyleBaseId: ShowStyleBaseId
) {
const allReady = [
useSubscription(CorelibPubSub.rundownPlaylists, {
_id: rundownPlaylistId,
}),
useSubscription(CorelibPubSub.rundowns, [rundownPlaylistId], null),

useSubscription(CorelibPubSub.adLibActions, {
rundownId: {
$in: rundownIds,
},
}),
useSubscription(CorelibPubSub.adLibPieces, {
rundownId: {
$in: rundownIds,
},
}),
useSubscription(CorelibPubSub.rundownBaselineAdLibActions, {
rundownId: {
$in: rundownIds,
},
}),
useSubscription(CorelibPubSub.rundownBaselineAdLibPieces, {
rundownId: {
$in: rundownIds,
},
}),
useSubscription(CorelibPubSub.rundownPlaylists, [rundownPlaylistId], null),
useSubscription(CorelibPubSub.rundownsInPlaylists, [rundownPlaylistId]),

useSubscription(CorelibPubSub.adLibActions, rundownIds),
useSubscription(CorelibPubSub.adLibPieces, rundownIds),
useSubscription(CorelibPubSub.rundownBaselineAdLibActions, rundownIds),
useSubscription(CorelibPubSub.rundownBaselineAdLibPieces, rundownIds),
useSubscription(MeteorPubSub.uiShowStyleBase, showStyleBaseId),
]

Expand Down
2 changes: 1 addition & 1 deletion meteor/client/ui/Account/OrganizationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const OrganizationPage = translateWithTracker(() => {
componentDidMount(): void {
this.autorun(() => {
if (this.props.organization) {
this.subscribe(MeteorPubSub.usersInOrganization, { organizationId: this.props.organization._id })
this.subscribe(MeteorPubSub.usersInOrganization, this.props.organization._id)
}
})
}
Expand Down
6 changes: 1 addition & 5 deletions meteor/client/ui/ActiveRundownView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ import { UIStudios } from './Collections'
import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { RundownPlaylists } from '../collections'
import { useTranslation } from 'react-i18next'
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'

export function ActiveRundownView({ studioId }: { studioId: StudioId }): JSX.Element | null {
const { t } = useTranslation()

const { path } = useRouteMatch()

const studioReady = useSubscription(MeteorPubSub.uiStudio, studioId)
const playlistReady = useSubscription(CorelibPubSub.rundownPlaylists, {
activationId: { $exists: true },
studioId,
})
const playlistReady = useSubscription(MeteorPubSub.rundownPlaylistForStudio, studioId, true)

const subsReady = studioReady && playlistReady

Expand Down
2 changes: 1 addition & 1 deletion meteor/client/ui/ClipTrimPanel/ClipTrimPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function ClipTrimPanel({
}: IProps): JSX.Element {
const { t } = useTranslation()

useSubscription(CorelibPubSub.pieces, { _id: pieceId, startRundownId: rundownId })
useSubscription(CorelibPubSub.pieces, [rundownId], null) // TODO: This should filter by pieceId, but that requires a different publication and this panel isnt used

const piece = useTracker(() => Pieces.findOne(pieceId), [pieceId])

Expand Down
24 changes: 6 additions & 18 deletions meteor/client/ui/ClockView/CameraScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,17 @@ export function CameraScreen({ playlist, studioId }: IProps): JSX.Element | null
const rundownIds = useMemo(() => rundowns.map((rundown) => rundown._id), [rundowns])
const showStyleBaseIds = useMemo(() => rundowns.map((rundown) => rundown.showStyleBaseId), [rundowns])

const rundownsReady = useSubscription(CorelibPubSub.rundowns, playlistIds, null)
useSubscription(CorelibPubSub.segments, {
rundownId: {
$in: rundownIds,
},
})
const rundownsReady = useSubscription(CorelibPubSub.rundownsInPlaylists, playlistIds)
useSubscription(CorelibPubSub.segments, rundownIds, {})

const studioReady = useSubscription(MeteorPubSub.uiStudio, studioId)
useSubscription(CorelibPubSub.partInstances, rundownIds, playlist?.activationId)
useSubscription(CorelibPubSub.partInstances, rundownIds, playlist?.activationId ?? null)

useSubscription(CorelibPubSub.parts, rundownIds)
useSubscription(CorelibPubSub.parts, rundownIds, null)

useSubscription(CorelibPubSub.pieceInstancesSimple, {
rundownId: {
$in: rundownIds,
},
})
useSubscription(CorelibPubSub.pieceInstancesSimple, rundownIds, null)

const piecesReady = useSubscription(CorelibPubSub.pieces, {
startRundownId: {
$in: rundownIds,
},
})
const piecesReady = useSubscription(CorelibPubSub.pieces, rundownIds, null)

const [piecesReadyOnce, setPiecesReadyOnce] = useState(false)
useEffect(() => {
Expand Down
7 changes: 2 additions & 5 deletions meteor/client/ui/ClockView/ClockView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import { OverlayScreenSaver } from './OverlayScreenSaver'
import { RundownPlaylists } from '../../collections'
import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { CameraScreen } from './CameraScreen'
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
import { MeteorPubSub } from '../../../lib/api/pubsub'

export function ClockView({ studioId }: { studioId: StudioId }): JSX.Element {
useSubscription(CorelibPubSub.rundownPlaylists, {
activationId: { $exists: true },
studioId,
})
useSubscription(MeteorPubSub.rundownPlaylistForStudio, studioId, true)

const playlist = useTracker(
() =>
Expand Down
3 changes: 1 addition & 2 deletions meteor/client/ui/ClockView/OverlayScreenSaver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { findNextPlaylist } from '../StudioScreenSaver/StudioScreenSaver'
// @ts-expect-error No types available
import Velocity from 'velocity-animate'
import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'

export function OverlayScreenSaver({ studioId }: { studioId: StudioId }): JSX.Element {
const studioNameRef = useRef<HTMLDivElement>(null)
Expand All @@ -19,7 +18,7 @@ export function OverlayScreenSaver({ studioId }: { studioId: StudioId }): JSX.El
})

useSubscription(MeteorPubSub.uiStudio, studioId)
useSubscription(CorelibPubSub.rundownPlaylists, { studioId: studioId, activationId: { $exists: false } })
useSubscription(MeteorPubSub.rundownPlaylistForStudio, studioId, false)

const data = useTracker(() => findNextPlaylist({ studioId }), [studioId])

Expand Down
37 changes: 13 additions & 24 deletions meteor/client/ui/ClockView/PresenterScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class PresenterScreenBase extends MeteorReactComponent<
},
}) as Pick<DBRundownPlaylist, '_id' | 'activationId'> | undefined
if (playlist) {
this.subscribe(CorelibPubSub.rundowns, [playlist._id], null)
this.subscribe(CorelibPubSub.rundownsInPlaylists, [playlist._id])

this.autorun(() => {
const rundowns = RundownPlaylistCollectionUtil.getRundownsUnordered(playlist, undefined, {
Expand All @@ -329,26 +329,16 @@ export class PresenterScreenBase extends MeteorReactComponent<
const showStyleBaseIds = rundowns.map((r) => r.showStyleBaseId)
const showStyleVariantIds = rundowns.map((r) => r.showStyleVariantId)

this.subscribe(CorelibPubSub.segments, {
rundownId: { $in: rundownIds },
})
this.subscribe(CorelibPubSub.parts, rundownIds)
this.subscribe(CorelibPubSub.partInstances, rundownIds, playlist.activationId)
this.subscribe(CorelibPubSub.segments, rundownIds, {})
this.subscribe(CorelibPubSub.parts, rundownIds, null)
this.subscribe(CorelibPubSub.partInstances, rundownIds, playlist.activationId ?? null)

for (const rundown of rundowns) {
this.subscribe(MeteorPubSub.uiShowStyleBase, rundown.showStyleBaseId)
}

this.subscribe(CorelibPubSub.showStyleVariants, {
_id: {
$in: showStyleVariantIds,
},
})
this.subscribe(MeteorPubSub.rundownLayouts, {
showStyleBaseId: {
$in: showStyleBaseIds,
},
})
this.subscribe(CorelibPubSub.showStyleVariants, null, showStyleVariantIds)
this.subscribe(MeteorPubSub.rundownLayouts, showStyleBaseIds)

this.autorun(() => {
const playlistR = RundownPlaylists.findOne(this.props.playlistId, {
Expand All @@ -363,16 +353,15 @@ export class PresenterScreenBase extends MeteorReactComponent<
const { nextPartInstance, currentPartInstance } =
RundownPlaylistCollectionUtil.getSelectedPartInstances(playlistR)
if (currentPartInstance) {
this.subscribe(CorelibPubSub.pieceInstances, {
rundownId: currentPartInstance.rundownId,
partInstanceId: currentPartInstance._id,
})
this.subscribe(
CorelibPubSub.pieceInstances,
[currentPartInstance.rundownId],
[currentPartInstance._id],
{}
)
}
if (nextPartInstance) {
this.subscribe(CorelibPubSub.pieceInstances, {
rundownId: nextPartInstance.rundownId,
partInstanceId: nextPartInstance._id,
})
this.subscribe(CorelibPubSub.pieceInstances, [nextPartInstance.rundownId], [nextPartInstance._id], {})
}
}
})
Expand Down
62 changes: 12 additions & 50 deletions meteor/client/ui/MediaStatus/MediaStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,61 +257,23 @@ function useMediaStatusSubscriptions(
): boolean {
const readyStatus: boolean[] = []
let counter = 0
readyStatus[counter++] = useSubscription(CorelibPubSub.rundownPlaylists, {
_id: {
$in: playlistIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.rundowns, playlistIds, null)
readyStatus[counter++] = useSubscription(CorelibPubSub.rundownPlaylists, playlistIds, null)
readyStatus[counter++] = useSubscription(CorelibPubSub.rundownsInPlaylists, playlistIds)
const uiShowStyleBaseSubArguments = useMemo(
() => showStyleBaseIds.map((showStyleBaseId) => [showStyleBaseId] as [ShowStyleBaseId]),
[showStyleBaseIds]
)
readyStatus[counter++] = useSubscriptions(MeteorPubSub.uiShowStyleBase, uiShowStyleBaseSubArguments)
readyStatus[counter++] = useSubscription(CorelibPubSub.segments, {
rundownId: {
$in: rundownIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.parts, rundownIds)
readyStatus[counter++] = useSubscription(CorelibPubSub.partInstancesSimple, {
rundownId: {
$in: rundownIds,
},
reset: {
$ne: true,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.pieceInstancesSimple, {
rundownId: {
$in: rundownIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.pieces, {
startRundownId: {
$in: rundownIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.adLibActions, {
rundownId: {
$in: rundownIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.adLibPieces, {
rundownId: {
$in: rundownIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.rundownBaselineAdLibActions, {
rundownId: {
$in: rundownIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.rundownBaselineAdLibPieces, {
rundownId: {
$in: rundownIds,
},
})
readyStatus[counter++] = useSubscription(CorelibPubSub.segments, rundownIds, {})
readyStatus[counter++] = useSubscription(CorelibPubSub.parts, rundownIds, null)
readyStatus[counter++] = useSubscription(CorelibPubSub.partInstancesSimple, rundownIds, null)
readyStatus[counter++] = useSubscription(CorelibPubSub.pieceInstancesSimple, rundownIds, null)
readyStatus[counter++] = useSubscription(CorelibPubSub.pieces, rundownIds, null)
readyStatus[counter++] = useSubscription(CorelibPubSub.adLibActions, rundownIds)
readyStatus[counter++] = useSubscription(CorelibPubSub.adLibPieces, rundownIds)
readyStatus[counter++] = useSubscription(CorelibPubSub.rundownBaselineAdLibActions, rundownIds)
readyStatus[counter++] = useSubscription(CorelibPubSub.rundownBaselineAdLibPieces, rundownIds)

const uiPieceContentStatusesSubArguments = useMemo(
() => playlistIds.map((playlistIds) => [playlistIds] as [RundownPlaylistId]),
[playlistIds]
Expand Down
5 changes: 1 addition & 4 deletions meteor/client/ui/PieceIcons/PieceCountdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ export function PieceCountdownContainer(props: IPropsHeader): JSX.Element | null
}
)

useSubscription(CorelibPubSub.pieceInstancesSimple, {
rundownId: { $in: props.rundownIds },
playlistActivationId: props.playlistActivationId,
})
useSubscription(CorelibPubSub.pieceInstancesSimple, props.rundownIds, props.playlistActivationId ?? null)

useSubscription(MeteorPubSub.uiShowStyleBase, props.showStyleBaseId)

Expand Down
5 changes: 1 addition & 4 deletions meteor/client/ui/PieceIcons/PieceIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ export function PieceIconContainer(props: IPropsHeader): JSX.Element | null {
}
)

useSubscription(CorelibPubSub.pieceInstancesSimple, {
rundownId: { $in: props.rundownIds },
playlistActivationId: props.playlistActivationId,
})
useSubscription(CorelibPubSub.pieceInstancesSimple, props.rundownIds, props.playlistActivationId ?? null)

useSubscription(MeteorPubSub.uiShowStyleBase, props.showStyleBaseId)

Expand Down
5 changes: 1 addition & 4 deletions meteor/client/ui/PieceIcons/PieceName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export function PieceNameContainer(props: INamePropsHeader): JSX.Element | null
}
)

useSubscription(CorelibPubSub.pieceInstancesSimple, {
rundownId: { $in: props.rundownIds },
playlistActivationId: props.playlistActivationId,
})
useSubscription(CorelibPubSub.pieceInstancesSimple, props.rundownIds, props.playlistActivationId ?? null)

useSubscription(MeteorPubSub.uiShowStyleBase, props.showStyleBaseId)

Expand Down
26 changes: 8 additions & 18 deletions meteor/client/ui/Prompter/PrompterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ export class PrompterViewInner extends MeteorReactComponent<Translated<IProps &
if (this.props.studioId) {
this.subscribe(MeteorPubSub.uiStudio, this.props.studioId)

this.subscribe(CorelibPubSub.rundownPlaylists, {
activationId: { $exists: true },
studioId: this.props.studioId,
})
this.subscribe(MeteorPubSub.rundownPlaylistForStudio, this.props.studioId, true)
}

this.autorun(() => {
Expand All @@ -225,7 +222,7 @@ export class PrompterViewInner extends MeteorReactComponent<Translated<IProps &
}
) as Pick<DBRundownPlaylist, '_id'> | undefined
if (playlist?._id) {
this.subscribe(CorelibPubSub.rundowns, [playlist._id], null)
this.subscribe(CorelibPubSub.rundownsInPlaylists, [playlist._id])
}
})

Expand Down Expand Up @@ -599,7 +596,7 @@ export const Prompter = translateWithTracker<PropsWithChildren<IPrompterProps>,
}

componentDidMount(): void {
this.subscribe(CorelibPubSub.rundowns, [this.props.rundownPlaylistId], null)
this.subscribe(CorelibPubSub.rundownsInPlaylists, [this.props.rundownPlaylistId])

this.autorun(() => {
const playlist = RundownPlaylists.findOne(this.props.rundownPlaylistId, {
Expand All @@ -610,18 +607,11 @@ export const Prompter = translateWithTracker<PropsWithChildren<IPrompterProps>,
}) as Pick<DBRundownPlaylist, '_id' | 'activationId'> | undefined
if (playlist) {
const rundownIDs = RundownPlaylistCollectionUtil.getRundownUnorderedIDs(playlist)
this.subscribe(CorelibPubSub.segments, {
rundownId: { $in: rundownIDs },
})
this.subscribe(CorelibPubSub.parts, rundownIDs)
this.subscribe(CorelibPubSub.partInstances, rundownIDs, playlist.activationId)
this.subscribe(CorelibPubSub.pieces, {
startRundownId: { $in: rundownIDs },
})
this.subscribe(CorelibPubSub.pieceInstancesSimple, {
rundownId: { $in: rundownIDs },
reset: { $ne: true },
})
this.subscribe(CorelibPubSub.segments, rundownIDs, {})
this.subscribe(CorelibPubSub.parts, rundownIDs, null)
this.subscribe(CorelibPubSub.partInstances, rundownIDs, playlist.activationId ?? null)
this.subscribe(CorelibPubSub.pieces, rundownIDs, null)
this.subscribe(CorelibPubSub.pieceInstancesSimple, rundownIDs, null)
}
})

Expand Down
15 changes: 5 additions & 10 deletions meteor/client/ui/RundownList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,14 @@ export function RundownList(): JSX.Element {
)

const baseSubsReady = [
useSubscription(CorelibPubSub.rundownPlaylists, {}),
useSubscription(CorelibPubSub.rundownPlaylists, null, null),
useSubscription(MeteorPubSub.uiStudio, null),
useSubscription(MeteorPubSub.rundownLayouts, {}),
useSubscription(MeteorPubSub.rundownLayouts, null),

useSubscription(CorelibPubSub.rundowns, playlistIds, null),
useSubscription(CorelibPubSub.rundownsInPlaylists, playlistIds),

useSubscription(CorelibPubSub.showStyleBases, {
_id: { $in: showStyleBaseIds },
}),

useSubscription(CorelibPubSub.showStyleVariants, {
_id: { $in: showStyleVariantIds },
}),
useSubscription(CorelibPubSub.showStyleBases, showStyleBaseIds),
useSubscription(CorelibPubSub.showStyleVariants, null, showStyleVariantIds),
].reduce((prev, current) => prev && current, true)

const [subsReady, setSubsReady] = useState(false)
Expand Down
Loading
Loading