mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 03:43:50 +00:00
refactor(rundown): simplify gap and overlap accumulation
The gap/overlap detection is already a merge-intervals sweep: `latestEvent` is the running max end and `getTimeFrom` is `start - maxEnd`. Making that explicit collapses the branching around it. - getTimeFrom: the three branches all returned the same subtraction - totalDuration: the gap === 0 / gap > 0 / gap < 0 cases are all Math.max(duration + gap, 0), since duration is never negative Same behaviour, no signature changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016XSraCPafWbAg35gAFrtgH
This commit is contained in:
@@ -17,17 +17,11 @@ export function getTimeFrom(
|
||||
const normalisedCurrentStart = current.timeStart + current.dayOffset * dayInMs;
|
||||
const normalisedPreviousEnd = previous.timeStart + previous.duration + previous.dayOffset * dayInMs;
|
||||
|
||||
// event is linked to previous
|
||||
if (normalisedCurrentStart === normalisedPreviousEnd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// event has a gap from previous
|
||||
if (normalisedCurrentStart > normalisedPreviousEnd) {
|
||||
// time from previous is difference between start and previous end
|
||||
return normalisedCurrentStart - normalisedPreviousEnd;
|
||||
}
|
||||
|
||||
// event overlaps with previous
|
||||
/**
|
||||
* The distance between the current start and the previous end
|
||||
* - positive: there is a gap between the events
|
||||
* - zero: the current event starts on the previous end
|
||||
* - negative: the events overlap
|
||||
*/
|
||||
return normalisedCurrentStart - normalisedPreviousEnd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user