diff --git a/apps/server/src/api-data/rundown/__tests__/rundown.dao.test.ts b/apps/server/src/api-data/rundown/__tests__/rundown.dao.test.ts index 76ef60818..4073227a3 100644 --- a/apps/server/src/api-data/rundown/__tests__/rundown.dao.test.ts +++ b/apps/server/src/api-data/rundown/__tests__/rundown.dao.test.ts @@ -432,6 +432,40 @@ describe('processRundown()', () => { expect(initResult.totalDuration).toBe(500 - 100); }); + it('skipped events do not advance day offsets or affect gaps', () => { + const rundown = makeRundown({ + order: ['1', 'skipped', '2'], + entries: { + '1': makeOntimeEvent({ + id: '1', + timeStart: 22 * MILLIS_PER_HOUR + 30 * MILLIS_PER_MINUTE, // 22:30:00 + timeEnd: 30 * MILLIS_PER_MINUTE, // 00:30:00 + duration: 2 * MILLIS_PER_HOUR, // 02:00:00 + }), + skipped: makeOntimeEvent({ + id: 'skipped', + skip: true, + timeStart: 22 * MILLIS_PER_HOUR + 30 * MILLIS_PER_MINUTE, // 22:30:00 + timeEnd: 30 * MILLIS_PER_MINUTE, // 00:30:00 + duration: 2 * MILLIS_PER_HOUR, // 02:00:00 + }), + '2': makeOntimeEvent({ + id: '2', + timeStart: 30 * MILLIS_PER_MINUTE, // 00:30:00 + timeEnd: 8 * MILLIS_PER_HOUR + 30 * MILLIS_PER_MINUTE, // 08:30:00 + duration: 8 * MILLIS_PER_HOUR, // 08:00:00 + }), + }, + }); + + const initResult = processRundown(rundown, {}); + + expect((initResult.entries.skipped as OntimeEvent).dayOffset).toBe(0); + expect((initResult.entries.skipped as OntimeEvent).gap).toBe(0); + expect((initResult.entries['2'] as OntimeEvent).dayOffset).toBe(1); + expect((initResult.entries['2'] as OntimeEvent).gap).toBe(0); + }); + it('calculates total duration across days with gap', () => { const rundown = makeRundown({ order: ['1', '2', '3'], diff --git a/apps/server/src/api-data/rundown/rundown.parser.ts b/apps/server/src/api-data/rundown/rundown.parser.ts index e6e9eb6bc..e269490e9 100644 --- a/apps/server/src/api-data/rundown/rundown.parser.ts +++ b/apps/server/src/api-data/rundown/rundown.parser.ts @@ -279,14 +279,22 @@ function processEntry( // 2. handle custom fields - mutates entry sanitiseCustomFields(customFields, entry); - rundownMetadata.totalDays += calculateDayOffset(entry, rundownMetadata.previousEvent); - entry.dayOffset = rundownMetadata.totalDays as Day; - entry.delay = 0; // this means we dont calculate delays or gaps for skipped events - entry.gap = 0; // this means we dont calculate delays or gaps for skipped events + /* + * we initialise data so that is not calculated for skipped events + * consider especially the day offset, while skipped events have no + * day offset, we match it to the previous element to avoid + * pushing confusing data to the UI + */ + entry.dayOffset = (rundownMetadata.previousEvent?.dayOffset ?? 0) as Day; + entry.delay = 0; + entry.gap = 0; + entry.parent = childOfGroup; // update rundown metadata, it only concerns playable events if (isPlayableEvent(entry)) { + rundownMetadata.totalDays += calculateDayOffset(entry, rundownMetadata.previousEvent); + entry.dayOffset = rundownMetadata.totalDays as Day; rundownMetadata.playableEventOrder.push(entry.id); // first start is always the first event