refactor: remove unused and legacy code

- remove legacy migrations
- remove unused server code
- remove unused UI code
This commit is contained in:
Carlos Valente
2025-03-07 23:02:32 +01:00
committed by Carlos Valente
parent fe8bbd5003
commit 95f2ba37cc
49 changed files with 64 additions and 1083 deletions
@@ -1,6 +1,5 @@
import {
CustomFields,
EndAction,
EventCustomFields,
OntimeBlock,
OntimeDelay,
@@ -8,11 +7,9 @@ import {
OntimeRundown,
SupportedEvent,
TimeStrategy,
TimerType,
} from 'ontime-types';
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE, dayInMs } from 'ontime-utils';
import { calculateRuntimeDelays, getDelayAt, calculateRuntimeDelaysFrom } from '../delayUtils.js';
import {
add,
batchEdit,
@@ -557,410 +554,6 @@ describe('swap() mutation', () => {
});
});
describe('calculateRuntimeDelays', () => {
it('calculates all delays in a given rundown', () => {
const rundown: OntimeRundown = [
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
timeEnd: 1200000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
delay: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '659e1',
cue: '1',
custom: {},
},
{
duration: 600000,
type: SupportedEvent.Delay,
id: '07986',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
timeEnd: 1200000,
duration: 0,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
delay: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '1c48f',
cue: '2',
custom: {},
},
{
duration: 1200000,
type: SupportedEvent.Delay,
id: '7db42',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
timeEnd: 1200000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
delay: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: 'd48c2',
cue: '3',
custom: {},
},
{
title: '',
type: SupportedEvent.Block,
id: '9870d',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
timeEnd: 1800000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
delay: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '2f185',
cue: '4',
custom: {},
},
];
const updatedRundown = calculateRuntimeDelays(rundown);
expect(rundown.length).toBe(updatedRundown.length);
expect((updatedRundown[0] as OntimeEvent).delay).toBe(0);
expect((updatedRundown[2] as OntimeEvent).delay).toBe(600000);
expect((updatedRundown[4] as OntimeEvent).delay).toBe(600000 + 1200000);
expect((updatedRundown[6] as OntimeEvent).delay).toBe(0);
});
});
describe('getDelayAt()', () => {
const delayedRundown: OntimeRundown = [
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
timeEnd: 1200000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '659e1',
delay: 0,
dayOffset: 0,
gap: 0,
cue: '1',
custom: {},
},
{
duration: 600000,
type: SupportedEvent.Delay,
id: '07986',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
timeEnd: 1200000,
duration: 0,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '1c48f',
delay: 600000,
cue: '2',
custom: {},
},
{
duration: 1200000,
type: SupportedEvent.Delay,
id: '7db42',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
timeEnd: 1200000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: 'd48c2',
delay: 1800000,
cue: '3',
custom: {},
},
{
title: '',
type: SupportedEvent.Block,
id: '9870d',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
timeEnd: 1800000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '2f185',
delay: 0,
cue: '4',
custom: {},
},
];
it('calculates delay in a rundown', () => {
const delayAtStart = getDelayAt(0, delayedRundown);
const delayOnFirstEvent = getDelayAt(2, delayedRundown);
const delayOnSecondEvent = getDelayAt(4, delayedRundown);
const delayOnBlockedEvent = getDelayAt(0, delayedRundown);
expect(delayAtStart).toBe(0);
expect(delayOnFirstEvent).toBe(600000);
expect(delayOnSecondEvent).toBe(600000 + 1200000);
expect(delayOnBlockedEvent).toBe(0);
});
it('finds delay before a delay block', () => {
const valueOnFirstDelayBlock = getDelayAt(1, delayedRundown);
const valueOnSecondDelayBlock = getDelayAt(3, delayedRundown);
const valueAfterSecondDelayBlock = getDelayAt(4, delayedRundown);
expect(valueOnFirstDelayBlock).toBe(0);
expect(valueOnSecondDelayBlock).toBe(600000);
expect(valueAfterSecondDelayBlock).toBe(600000 + 1200000);
});
it('returns 0 after blocks', () => {
const valueOnBlock = getDelayAt(6, delayedRundown);
expect(valueOnBlock).toBe(0);
});
});
describe('calculateRuntimeDelaysFrom()', () => {
it('updates delays from given id', () => {
const delayedRundown: OntimeRundown = [
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
timeEnd: 1200000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '659e1',
delay: 0,
cue: '1',
custom: {},
},
{
duration: 600000,
type: SupportedEvent.Delay,
id: '07986',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
timeEnd: 1200000,
duration: 0,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '1c48f',
delay: 0,
cue: '2',
custom: {},
},
{
duration: 1200000,
type: SupportedEvent.Delay,
id: '7db42',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 600000,
timeEnd: 1200000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: 'd48c2',
delay: 1800000,
cue: '3',
custom: {},
},
{
title: '',
type: SupportedEvent.Block,
id: '9870d',
},
{
title: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
countToEnd: false,
timeStrategy: TimeStrategy.LockEnd,
linkStart: null,
timeStart: 1200000,
timeEnd: 1800000,
duration: 600000,
isPublic: true,
skip: false,
colour: '',
type: SupportedEvent.Event,
revision: 0,
dayOffset: 0,
gap: 0,
timeWarning: 120000,
timeDanger: 60000,
id: '2f185',
delay: 0,
cue: '4',
custom: {},
},
];
const updatedRundown = calculateRuntimeDelaysFrom('07986', delayedRundown);
// we only update from the 4th on
expect((updatedRundown[0] as OntimeEvent).delay).toBe(0);
// 1 + 3
expect((updatedRundown[4] as OntimeEvent).delay).toBe(600000 + 1200000);
});
});
describe('custom fields', () => {
describe('createCustomField()', () => {
it('creates a field from given parameters', () => {