mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 02:43:50 +00:00
refactor: remove unused and legacy code
- remove legacy migrations - remove unused server code - remove unused UI code
This commit is contained in:
committed by
Carlos Valente
parent
fe8bbd5003
commit
95f2ba37cc
@@ -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,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -305,7 +305,7 @@ export const parseExcel = (
|
||||
};
|
||||
};
|
||||
|
||||
export type ParsingError = {
|
||||
type ParsingError = {
|
||||
context: string;
|
||||
message: string;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user