|
1 | 1 | import { Piece } from '@sofie-automation/corelib/dist/dataModel/Piece' |
2 | | -import { IOutputLayer, ISourceLayer, ITranslatableMessage } from '@sofie-automation/blueprints-integration' |
| 2 | +import { IOutputLayer, ISourceLayer } from '@sofie-automation/blueprints-integration' |
3 | 3 | import { DBSegment, SegmentOrphanedReason } from '@sofie-automation/corelib/dist/dataModel/Segment' |
4 | 4 | import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part' |
5 | | -import { PartInstance, wrapPartToTemporaryInstance } from './collections/PartInstances' |
| 5 | +import { PartInstance, wrapPartToTemporaryInstance } from '../../lib/collections/PartInstances' |
6 | 6 | import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance' |
7 | 7 | import { |
8 | 8 | getPieceInstancesForPart, |
9 | 9 | buildPiecesStartingInThisPartQuery, |
10 | 10 | buildPastInfinitePiecesForThisPartQuery, |
11 | 11 | } from '@sofie-automation/corelib/dist/playout/infinites' |
12 | | -import { invalidateAfter } from '../lib/invalidatingTime' |
13 | | -import { getCurrentTime, groupByToMap, ProtectedString, protectString } from './lib' |
| 12 | +import { invalidateAfter } from '../../lib/invalidatingTime' |
| 13 | +import { getCurrentTime, groupByToMap, protectString } from '../../lib/lib' |
14 | 14 | import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist' |
15 | 15 | import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown' |
16 | | -import { isTranslatableMessage } from '@sofie-automation/corelib/dist/TranslatableMessage' |
17 | 16 | import { mongoWhereFilter, MongoQuery } from '@sofie-automation/corelib/dist/mongo' |
18 | | -import { FindOptions } from './collections/lib' |
| 17 | +import { FindOptions } from '../../lib/collections/lib' |
19 | 18 | import { |
20 | 19 | PartId, |
21 | 20 | RundownId, |
22 | 21 | RundownPlaylistActivationId, |
23 | 22 | SegmentId, |
24 | 23 | ShowStyleBaseId, |
25 | 24 | } from '@sofie-automation/corelib/dist/dataModel/Ids' |
26 | | -import { PieceInstances, Pieces } from './collections/libCollections' |
27 | | -import { RundownPlaylistCollectionUtil } from './collections/rundownPlaylistUtil' |
28 | | -import { PieceContentStatusObj } from './api/pieceContentStatus' |
| 25 | +import { PieceInstances, Pieces } from '../../lib/collections/libCollections' |
| 26 | +import { RundownPlaylistCollectionUtil } from '../../lib/collections/rundownPlaylistUtil' |
| 27 | +import { PieceContentStatusObj } from '../../lib/api/pieceContentStatus' |
29 | 28 | import { ReadonlyDeep } from 'type-fest' |
30 | 29 | import { PieceInstanceWithTimings } from '@sofie-automation/corelib/dist/playout/processAndPrune' |
31 | 30 |
|
@@ -322,85 +321,3 @@ export function getSegmentsWithPartInstances( |
322 | 321 | } |
323 | 322 | }) |
324 | 323 | } |
325 | | - |
326 | | -// 1 reactivelly listen to data changes |
327 | | -/* |
328 | | -setup () { |
329 | | - RundownPlaylists.find().observeChanges( |
330 | | - asdf: onReactiveDataChange |
331 | | - ) |
332 | | -} |
333 | | -
|
334 | | -onReactiveDataChange () { |
335 | | - setTimeoutIgnore(() => { |
336 | | - updateCalculatedData() |
337 | | - }, 200) |
338 | | -} |
339 | | -
|
340 | | -const cachedSegments = {} |
341 | | -updateCalculatedData () { |
342 | | -
|
343 | | - const data = calculateBigDataSet() |
344 | | -
|
345 | | - data.segments |
346 | | -} |
347 | | -*/ |
348 | | - |
349 | | -function compareLabels(a: string | ITranslatableMessage, b: string | ITranslatableMessage) { |
350 | | - const actualA = isTranslatableMessage(a) ? a.key : (a as string) |
351 | | - const actualB = isTranslatableMessage(b) ? b.key : (b as string) |
352 | | - // can't use .localeCompare, because this needs to be locale-independent and always return |
353 | | - // the same sorting order, because that's being relied upon by limit & pick/pickEnd. |
354 | | - if (actualA > actualB) return 1 |
355 | | - if (actualA < actualB) return -1 |
356 | | - return 0 |
357 | | -} |
358 | | - |
359 | | -/** Sort a list of adlibs */ |
360 | | -export function sortAdlibs<T>( |
361 | | - adlibs: { |
362 | | - adlib: T |
363 | | - label: string | ITranslatableMessage |
364 | | - adlibRank: number |
365 | | - adlibId: ProtectedString<any> | string |
366 | | - partRank: number | null |
367 | | - segmentRank: number | null |
368 | | - rundownRank: number | null |
369 | | - }[] |
370 | | -): T[] { |
371 | | - adlibs = adlibs.sort((a, b) => { |
372 | | - // Sort by rundown rank, where applicable: |
373 | | - a.rundownRank = a.rundownRank ?? Number.POSITIVE_INFINITY |
374 | | - b.rundownRank = b.rundownRank ?? Number.POSITIVE_INFINITY |
375 | | - if (a.rundownRank > b.rundownRank) return 1 |
376 | | - if (a.rundownRank < b.rundownRank) return -1 |
377 | | - |
378 | | - // Sort by segment rank, where applicable: |
379 | | - a.segmentRank = a.segmentRank ?? Number.POSITIVE_INFINITY |
380 | | - b.segmentRank = b.segmentRank ?? Number.POSITIVE_INFINITY |
381 | | - if (a.segmentRank > b.segmentRank) return 1 |
382 | | - if (a.segmentRank < b.segmentRank) return -1 |
383 | | - |
384 | | - // Sort by part rank, where applicable: |
385 | | - a.partRank = a.partRank ?? Number.POSITIVE_INFINITY |
386 | | - b.partRank = b.partRank ?? Number.POSITIVE_INFINITY |
387 | | - if (a.partRank > b.partRank) return 1 |
388 | | - if (a.partRank < b.partRank) return -1 |
389 | | - |
390 | | - // Sort by adlib rank |
391 | | - if (a.adlibRank > b.adlibRank) return 1 |
392 | | - if (a.adlibRank < b.adlibRank) return -1 |
393 | | - |
394 | | - // Sort by labels: |
395 | | - const r = compareLabels(a.label, b.label) |
396 | | - if (r !== 0) return r |
397 | | - |
398 | | - // As a last resort, sort by ids: |
399 | | - if (a.adlibId > b.adlibId) return 1 |
400 | | - if (a.adlibId < b.adlibId) return -1 |
401 | | - |
402 | | - return 0 |
403 | | - }) |
404 | | - |
405 | | - return adlibs.map((a) => a.adlib) |
406 | | -} |
0 commit comments