refactor: recover day after indicator

This commit is contained in:
Carlos Valente
2024-05-17 22:38:31 +02:00
committed by Carlos Valente
parent 4069038ed5
commit eb2c4d0780
5 changed files with 22 additions and 18 deletions
@@ -9,7 +9,7 @@ import {
OntimeRundown,
OntimeRundownEntry,
} from 'ontime-types';
import { generateId, deleteAtIndex, insertAtIndex, reorderArray, swapEventData } from 'ontime-utils';
import { generateId, deleteAtIndex, insertAtIndex, reorderArray, swapEventData, checkIsNextDay } from 'ontime-utils';
import { DataProvider } from '../../classes/data-provider/DataProvider.js';
import { createPatch } from '../../utils/parser.js';
@@ -85,6 +85,7 @@ export function generate(
let accumulatedDelay = 0;
let daySpan = 0;
let previousStart: MaybeNumber = null;
let previousEnd: MaybeNumber = null;
for (let i = 0; i < initialRundown.length; i++) {
@@ -108,7 +109,7 @@ export function generate(
lastEnd = updatedEvent.timeEnd;
// check if we go over midnight, account for eventual gaps
const gapOverMidnight = previousEnd !== null && previousEnd > updatedEvent.timeStart;
const gapOverMidnight = previousStart !== null && checkIsNextDay(previousStart, updatedEvent.timeStart);
const durationOverMidnight = updatedEvent.timeStart > updatedEvent.timeEnd;
if (gapOverMidnight || durationOverMidnight) {
daySpan++;
@@ -128,6 +129,7 @@ export function generate(
accumulatedDelay = Math.max(accumulatedDelay - gap, 0);
}
updatedEvent.delay = accumulatedDelay;
previousStart = updatedEvent.timeStart;
previousEnd = updatedEvent.timeEnd;
}
+1 -1
View File
@@ -123,7 +123,7 @@ export function updateRundownData(rundownData: RundownData) {
runtimeState.runtime.numEvents = rundownData.numEvents;
runtimeState.runtime.plannedStart = rundownData.firstStart;
runtimeState.runtime.plannedEnd = rundownData.lastEnd;
runtimeState.runtime.plannedEnd = rundownData.firstStart + rundownData.totalDuration;
runtimeState.runtime.expectedEnd = getExpectedEnd(runtimeState);
}