mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-13 11:23:50 +00:00
Invert overtime (#1715)
* refactor: invert offset calculation * chore: update tests * chore: flip offset in UI * fix seconds display on group target duration * update comment * fix rebase
This commit is contained in:
committed by
Carlos Valente
parent
4665f9c2f7
commit
e0149c1cbf
@@ -33,7 +33,7 @@ describe('getExpectedStart()', () => {
|
||||
const testState = {
|
||||
currentDay: 0,
|
||||
totalGap: 0,
|
||||
offset: -20,
|
||||
offset: 20,
|
||||
offsetMode: OffsetMode.Absolute,
|
||||
actualStart: null,
|
||||
plannedStart: null,
|
||||
@@ -52,7 +52,7 @@ describe('getExpectedStart()', () => {
|
||||
const testState = {
|
||||
currentDay: 0,
|
||||
totalGap: 0,
|
||||
offset: 10,
|
||||
offset: -10,
|
||||
offsetMode: OffsetMode.Absolute,
|
||||
actualStart: null,
|
||||
plannedStart: null,
|
||||
@@ -71,7 +71,7 @@ describe('getExpectedStart()', () => {
|
||||
const testState = {
|
||||
currentDay: 0,
|
||||
totalGap: 20,
|
||||
offset: -20,
|
||||
offset: 20,
|
||||
offsetMode: OffsetMode.Absolute,
|
||||
actualStart: null,
|
||||
plannedStart: null,
|
||||
@@ -90,7 +90,7 @@ describe('getExpectedStart()', () => {
|
||||
const testState = {
|
||||
currentDay: 0,
|
||||
totalGap: 10,
|
||||
offset: -20,
|
||||
offset: 20,
|
||||
offsetMode: OffsetMode.Absolute,
|
||||
actualStart: 0,
|
||||
plannedStart: 0,
|
||||
@@ -219,12 +219,12 @@ describe('getExpectedStart()', () => {
|
||||
expect(getExpectedStart(testEvent, { ...testState, isLinkedToLoaded: true })).toBe(120);
|
||||
expect(getExpectedStart(testEvent, { ...testState, isLinkedToLoaded: false })).toBe(120);
|
||||
|
||||
testState.offset = 5; // remove 5 with addtime - we are ahead of time
|
||||
testState.offset = -5; // remove 5 with addtime - we are ahead of time
|
||||
|
||||
expect(getExpectedStart(testEvent, { ...testState, isLinkedToLoaded: true })).toBe(115);
|
||||
expect(getExpectedStart(testEvent, { ...testState, isLinkedToLoaded: false })).toBe(120); // unlocked evets will stay on schedule
|
||||
expect(getExpectedStart(testEvent, { ...testState, isLinkedToLoaded: false })).toBe(120); // unlinked events will stay on schedule
|
||||
|
||||
testState.offset = -5; // add 5 with addtime - we are behind
|
||||
testState.offset = +5; // add 5 with addtime - we are behind
|
||||
|
||||
expect(getExpectedStart(testEvent, { ...testState, isLinkedToLoaded: true })).toBe(125);
|
||||
expect(getExpectedStart(testEvent, { ...testState, isLinkedToLoaded: false })).toBe(125);
|
||||
|
||||
@@ -43,14 +43,14 @@ export function getExpectedStart(
|
||||
|
||||
const scheduledStartTime = normalisedTimeStart + relativeStartOffset;
|
||||
|
||||
const offsetStartTime = scheduledStartTime - offset;
|
||||
const offsetStartTime = scheduledStartTime + offset;
|
||||
|
||||
if (isLinkedToLoaded) {
|
||||
//if we are directly linked back to the loaded event we just follow the offset
|
||||
return offsetStartTime;
|
||||
}
|
||||
|
||||
const gapsCanCompensateForOffset = totalGap + offset >= 0;
|
||||
const gapsCanCompensateForOffset = totalGap > offset;
|
||||
if (gapsCanCompensateForOffset) {
|
||||
// if we are ahead of schedule or the gap can compensate for the amount we are behind then expect to start at the scheduled time
|
||||
return scheduledStartTime;
|
||||
|
||||
Reference in New Issue
Block a user