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,13 +1,10 @@
import {
CustomFields,
DatabaseModel,
EndAction,
OntimeEvent,
OntimeRundown,
Settings,
SupportedEvent,
TimeStrategy,
TimerType,
URLPreset,
} from 'ontime-types';
@@ -362,46 +359,3 @@ describe('parseRundown() linking', () => {
});
});
});
describe('parseRundown() migrations', () => {
const legacyEvent = {
id: '1',
type: SupportedEvent.Event,
cue: '',
title: '',
note: '',
endAction: EndAction.None,
timerType: 'time-to-end',
linkStart: null,
timeStrategy: TimeStrategy.LockDuration,
timeStart: 0,
timeEnd: 0,
duration: 0,
isPublic: false,
skip: false,
colour: '',
revision: 0,
timeWarning: 120000,
timeDanger: 60000,
custom: {},
};
it('migrates an event with time-to-end', () => {
const result = parseRundown({ rundown: [legacyEvent] as OntimeRundown });
expect(result.rundown[0]).toMatchObject({
id: '1',
timerType: TimerType.CountDown,
countToEnd: true,
});
});
it('migrates an event without time-to-end', () => {
const countdownEvent = { ...legacyEvent, timerType: TimerType.CountDown };
const result = parseRundown({ rundown: [countdownEvent] as OntimeRundown });
expect(result.rundown[0]).toMatchObject({
id: '1',
timerType: TimerType.CountDown,
countToEnd: false,
});
});
});
+1 -1
View File
@@ -305,7 +305,7 @@ export const parseExcel = (
};
};
export type ParsingError = {
type ParsingError = {
context: string;
message: string;
};
+1 -21
View File
@@ -8,7 +8,6 @@ import {
OntimeRundown,
ProjectData,
Settings,
TimerType,
URLPreset,
ViewSettings,
isOntimeBlock,
@@ -53,7 +52,7 @@ export function parseRundown(
let newEvent: OntimeEvent | OntimeDelay | OntimeBlock | null;
if (isOntimeEvent(event)) {
const maybeEvent = runEventMigrations({ ...event, id });
const maybeEvent = { ...event, id };
if (event.linkStart) {
maybeEvent.linkStart = previousId;
@@ -247,22 +246,3 @@ export function sanitiseCustomFields(data: object): CustomFields {
return newCustomFields;
}
/**
* 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.countToEnd = true;
}
return event;
}
/**
* Mutating function migrates event data entries
*/
function runEventMigrations(event: any): OntimeEvent {
return migrateTimeToEnd(event);
}
@@ -1,9 +0,0 @@
import { parse } from 'path';
/**
* @description Takes a filename and removes the extension
* @param {string} filename - filename with extension
*/
export const removeFileExtension = (filename: string): string => {
return parse(filename).name;
};
+14
View File
@@ -60,3 +60,17 @@ export function getTimezoneLabel(date: Date): string {
return `GMT ${sign}${pad(hours)}:${pad(minutes)} ${tzName}`;
}
/**
* Get current time from system
*/
export function timeNow() {
const now = new Date();
// extract milliseconds since midnight
let elapsed = now.getHours() * 3600000;
elapsed += now.getMinutes() * 60000;
elapsed += now.getSeconds() * 1000;
elapsed += now.getMilliseconds();
return elapsed;
}