chore: rename time-to-end to count-to-end

This commit is contained in:
Carlos Valente
2024-12-18 19:43:12 +01:00
committed by Carlos Valente
parent c9ef2465f8
commit 2f2c26ed00
30 changed files with 115 additions and 122 deletions
+14 -14
View File
@@ -10,7 +10,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.01',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 36000000,
@@ -35,7 +35,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.02',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 37500000,
@@ -60,7 +60,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.03',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 39000000,
@@ -85,7 +85,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.04',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 40500000,
@@ -110,7 +110,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.05',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 42000000,
@@ -140,7 +140,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.06',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 47100000,
@@ -165,7 +165,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.07',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 48600000,
@@ -190,7 +190,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.08',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 50100000,
@@ -215,7 +215,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.09',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 51600000,
@@ -240,7 +240,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.10',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 53100000,
@@ -270,7 +270,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.11',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 56100000,
@@ -295,7 +295,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.12',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 57600000,
@@ -320,7 +320,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.13',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 59100000,
@@ -345,7 +345,7 @@ export const demoDb: DatabaseModel = {
note: 'SF1.14',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
linkStart: null,
timeStrategy: TimeStrategy.LockEnd,
timeStart: 60600000,
+1 -1
View File
@@ -15,7 +15,7 @@ export const event: Omit<OntimeEvent, 'id' | 'delay' | 'cue'> = {
timerType: TimerType.CountDown,
timeStrategy: TimeStrategy.LockDuration,
linkStart: null,
isTimeToEnd: false,
countToEnd: false,
timeStart: 0,
timeEnd: 0,
duration: 0,
@@ -175,7 +175,7 @@ describe('getExpectedFinish()', () => {
const state = {
eventNow: {
timeEnd: 30,
isTimeToEnd: true,
countToEnd: true,
},
timer: {
addedTime: 10,
@@ -195,7 +195,7 @@ describe('getExpectedFinish()', () => {
const state = {
eventNow: {
timeEnd: 600000, // 00:10:00
isTimeToEnd: true,
countToEnd: true,
},
timer: {
addedTime: 0,
@@ -346,12 +346,12 @@ describe('getCurrent()', () => {
expect(current).toBe(35);
});
describe('on timers of type time-to-end', () => {
describe('on timers of type count-to-end', () => {
it('current time is the time to end even if it hasnt started, this is weird, but by design', () => {
const state = {
eventNow: {
timeEnd: 100,
isTimeToEnd: true,
countToEnd: true,
},
clock: 30,
timer: {
@@ -376,7 +376,7 @@ describe('getCurrent()', () => {
const state = {
eventNow: {
timeEnd: 100,
isTimeToEnd: true,
countToEnd: true,
},
clock: 30,
timer: {
@@ -401,7 +401,7 @@ describe('getCurrent()', () => {
const state = {
eventNow: {
timeEnd: 100,
isTimeToEnd: true,
countToEnd: true,
},
clock: 30,
timer: {
@@ -427,7 +427,7 @@ describe('getCurrent()', () => {
eventNow: {
timeStart: 79200000, // 22:00:00
timeEnd: 600000, // 00:10:00
isTimeToEnd: true,
countToEnd: true,
},
clock: 79500000, // 22:05:00
timer: {
@@ -456,7 +456,7 @@ describe('getCurrent()', () => {
timeStart: 77400000, // 21:30:00
timeEnd: 81000000, // 22:30:00
duration: 3600000, // 01:00:00
isTimeToEnd: true,
countToEnd: true,
},
timer: {
addedTime: 0,
@@ -910,7 +910,7 @@ describe('getRuntimeOffset()', () => {
linkStart: null,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: true,
countToEnd: true,
isPublic: true,
skip: false,
note: '',
@@ -963,7 +963,7 @@ describe('getRuntimeOffset()', () => {
linkStart: null,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: true,
countToEnd: true,
isPublic: true,
skip: false,
note: '',
@@ -1014,7 +1014,7 @@ describe('getRuntimeOffset()', () => {
linkStart: null,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: true,
countToEnd: true,
},
runtime: {
selectedEventIndex: 0,
@@ -565,7 +565,7 @@ describe('calculateRuntimeDelays', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
@@ -592,7 +592,7 @@ describe('calculateRuntimeDelays', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
@@ -619,7 +619,7 @@ describe('calculateRuntimeDelays', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
@@ -646,7 +646,7 @@ describe('calculateRuntimeDelays', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
@@ -682,7 +682,7 @@ describe('getDelayAt()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
@@ -710,7 +710,7 @@ describe('getDelayAt()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
@@ -738,7 +738,7 @@ describe('getDelayAt()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
@@ -766,7 +766,7 @@ describe('getDelayAt()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
@@ -820,7 +820,7 @@ describe('calculateRuntimeDelaysFrom()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
@@ -848,7 +848,7 @@ describe('calculateRuntimeDelaysFrom()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
@@ -876,7 +876,7 @@ describe('calculateRuntimeDelaysFrom()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
@@ -904,7 +904,7 @@ describe('calculateRuntimeDelaysFrom()', () => {
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
@@ -31,7 +31,7 @@ describe('cellRequestFromEvent()', () => {
linkStart: null,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
duration: 10800000,
isPublic: false,
skip: false,
@@ -74,7 +74,7 @@ describe('cellRequestFromEvent()', () => {
timeEnd: 57600000,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
duration: 10800000,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
@@ -121,7 +121,7 @@ describe('cellRequestFromEvent()', () => {
timeEnd: 57600000,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
duration: 10800000,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
@@ -167,7 +167,7 @@ describe('cellRequestFromEvent()', () => {
timeEnd: 57600000,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
duration: 10800000,
@@ -199,7 +199,7 @@ describe('cellRequestFromEvent()', () => {
timeEnd: 57600000,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
duration: 10800000,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
@@ -232,7 +232,7 @@ describe('cellRequestFromEvent()', () => {
timeEnd: 57600000,
endAction: EndAction.None,
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
duration: 10800000,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
+6 -6
View File
@@ -19,7 +19,7 @@ export function getExpectedFinish(state: RuntimeState): MaybeNumber {
return null;
}
const { isTimeToEnd, timeEnd } = state.eventNow;
const { countToEnd, timeEnd } = state.eventNow;
const { pausedAt } = state._timer;
const { clock } = state;
@@ -33,7 +33,7 @@ export function getExpectedFinish(state: RuntimeState): MaybeNumber {
const pausedTime = pausedAt != null ? clock - pausedAt : 0;
if (isTimeToEnd) {
if (countToEnd) {
return timeEnd + addedTime + pausedTime;
}
@@ -62,11 +62,11 @@ export function getCurrent(state: RuntimeState): number {
}
}
const { startedAt, duration, addedTime } = state.timer;
const { isTimeToEnd, timeStart, timeEnd } = state.eventNow;
const { countToEnd, timeStart, timeEnd } = state.eventNow;
const { pausedAt } = state._timer;
const { clock } = state;
if (isTimeToEnd) {
if (countToEnd) {
const isEventOverMidnight = timeStart > timeEnd;
const correctDay = isEventOverMidnight ? dayInMs : 0;
return correctDay - clock + timeEnd + addedTime;
@@ -131,7 +131,7 @@ export function getRuntimeOffset(state: RuntimeState): number {
}
const { clock } = state;
const { isTimeToEnd, timeStart } = state.eventNow;
const { countToEnd, timeStart } = state.eventNow;
const { addedTime, current, startedAt } = state.timer;
// if we havent started, but the timer is armed
@@ -142,7 +142,7 @@ export function getRuntimeOffset(state: RuntimeState): number {
const overtime = Math.min(current, 0);
// in time-to-end, offset is overtime
if (isTimeToEnd) {
if (countToEnd) {
return overtime;
}
@@ -471,7 +471,7 @@ describe('test event validator', () => {
note: expect.any(String),
timeStart: expect.any(Number),
timeEnd: expect.any(Number),
isTimeToEnd: expect.any(Boolean),
countToEnd: expect.any(Boolean),
isPublic: expect.any(Boolean),
skip: expect.any(Boolean),
revision: expect.any(Number),
@@ -775,7 +775,7 @@ describe('getCustomFieldData()', () => {
duration: 'duration',
cue: 'cue',
title: 'title',
isTimeToEnd: 'time to end',
countToEnd: 'count to end',
isPublic: 'public',
skip: 'skip',
note: 'notes',
@@ -826,7 +826,7 @@ describe('getCustomFieldData()', () => {
duration: 'duration',
cue: 'cue',
title: 'title',
isTimeToEnd: 'time to end',
countToEnd: 'count to end',
isPublic: 'public',
skip: 'skip',
note: 'notes',
@@ -886,7 +886,7 @@ describe('parseExcel()', () => {
'Title',
'End Action',
'Timer type',
'Time to end',
'Count to end',
'Public',
'Skip',
'Notes',
@@ -909,7 +909,7 @@ describe('parseExcel()', () => {
'Guest Welcome',
'',
'',
'x', // <-- time to end
'x', // <-- count to end
'x', // <-- public
'',
'Ballyhoo',
@@ -932,7 +932,7 @@ describe('parseExcel()', () => {
'A song from the hearth',
'load-next',
'clock',
'x', // <-- time to end
'x', // <-- count to end
'', // <-- public
'x',
'Rainbow chase',
@@ -977,7 +977,7 @@ describe('parseExcel()', () => {
timerType: 'count-down',
endAction: 'none',
isPublic: true,
isTimeToEnd: true,
countToEnd: true,
skip: false,
note: 'Ballyhoo',
custom: {
@@ -1001,7 +1001,7 @@ describe('parseExcel()', () => {
timeEnd: 30600000,
title: 'A song from the hearth',
timerType: 'clock',
isTimeToEnd: true,
countToEnd: true,
endAction: 'load-next',
isPublic: false,
skip: true,
@@ -532,7 +532,7 @@ describe('parseRundown() migrations', () => {
expect(result.rundown[0]).toMatchObject({
id: '1',
timerType: TimerType.CountDown,
isTimeToEnd: true,
countToEnd: true,
});
});
@@ -542,7 +542,7 @@ describe('parseRundown() migrations', () => {
expect(result.rundown[0]).toMatchObject({
id: '1',
timerType: TimerType.CountDown,
isTimeToEnd: false,
countToEnd: false,
});
});
});
+7 -7
View File
@@ -110,7 +110,7 @@ export const parseExcel = (
// options: booleans
let isPublicIndex: number | null = null;
let skipIndex: number | null = null;
let isTimeToEndIndex: number | null = null;
let countToEndIndex: number | null = null;
let linkStartIndex: number | null = null;
@@ -160,9 +160,9 @@ export const parseExcel = (
titleIndex = col;
rundownMetadata['title'] = { row, col };
},
[importMap.isTimeToEnd]: (row: number, col: number) => {
isTimeToEndIndex = col;
rundownMetadata['isTimeToEnd'] = { row, col };
[importMap.countToEnd]: (row: number, col: number) => {
countToEndIndex = col;
rundownMetadata['countToEnd'] = { row, col };
},
[importMap.isPublic]: (row: number, col: number) => {
isPublicIndex = col;
@@ -231,8 +231,8 @@ export const parseExcel = (
event.duration = parseExcelDate(column);
} else if (j === cueIndex) {
event.cue = makeString(column, '');
} else if (j === isTimeToEndIndex) {
event.isTimeToEnd = parseBooleanString(column);
} else if (j === countToEndIndex) {
event.countToEnd = parseBooleanString(column);
} else if (j === isPublicIndex) {
event.isPublic = parseBooleanString(column);
} else if (j === skipIndex) {
@@ -379,7 +379,7 @@ export function createPatch(originalEvent: OntimeEvent, patchEvent: Partial<Onti
linkStart: validateLinkStart(patchEvent.linkStart),
endAction: validateEndAction(patchEvent.endAction, originalEvent.endAction),
timerType: validateTimerType(patchEvent.timerType, originalEvent.timerType),
isTimeToEnd: typeof patchEvent.isTimeToEnd === 'boolean' ? patchEvent.isTimeToEnd : originalEvent.isTimeToEnd,
countToEnd: typeof patchEvent.countToEnd === 'boolean' ? patchEvent.countToEnd : originalEvent.countToEnd,
isPublic: typeof patchEvent.isPublic === 'boolean' ? patchEvent.isPublic : originalEvent.isPublic,
skip: typeof patchEvent.skip === 'boolean' ? patchEvent.skip : originalEvent.skip,
note: makeString(patchEvent.note, originalEvent.note),
+2 -2
View File
@@ -349,13 +349,13 @@ export function sanitiseCustomFields(data: object): CustomFields {
}
/**
* Time to end was moved from a TimerType to a standalone boolean
* Time to end was moved from a TimerType to a standalone boolean named count to end
* Released as part of v3.10.0
*/
function migrateTimeToEnd(event: any): OntimeEvent {
if (event.timerType === 'time-to-end') {
event.timerType = TimerType.CountDown;
event.isTimeToEnd = true;
event.countToEnd = true;
}
return event;
}