fix(rundown): prevent skipped events from influencing day calculations

This commit is contained in:
Carlos Valente
2026-07-18 13:03:06 +02:00
committed by Carlos Valente
parent 0c5e87b7e7
commit f234a1f892
2 changed files with 46 additions and 4 deletions
@@ -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'],
@@ -279,14 +279,22 @@ function processEntry<T extends OntimeEntry>(
// 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