mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
Small clean-up (#1827)
* chore: avoid shadow variable name * chore: map could just be foreach * clean uneeded template literal * lint
This commit is contained in:
committed by
GitHub
parent
9b36f36f73
commit
45e7373279
@@ -355,7 +355,7 @@ export function migrateRundown(
|
|||||||
const newCustom: EntryCustomFields = {};
|
const newCustom: EntryCustomFields = {};
|
||||||
|
|
||||||
if (translationTable) {
|
if (translationTable) {
|
||||||
Object.entries(custom).map(([key, value]) => {
|
Object.entries(custom).forEach(([key, value]) => {
|
||||||
const newKey = translationTable.get(key);
|
const newKey = translationTable.get(key);
|
||||||
if (newKey) {
|
if (newKey) {
|
||||||
newCustom[newKey] = value;
|
newCustom[newKey] = value;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ router.get('/:rundownId/export', validateRundownExport, (req: Request, res: Resp
|
|||||||
const customFields = getProjectCustomFields();
|
const customFields = getProjectCustomFields();
|
||||||
const buffer = generateExcelFile(rundown, customFields);
|
const buffer = generateExcelFile(rundown, customFields);
|
||||||
|
|
||||||
res.setHeader('Content-Disposition', `attachment;`);
|
res.setHeader('Content-Disposition', 'attachment;');
|
||||||
res.setHeader('Content-Type', EXCEL_MIME);
|
res.setHeader('Content-Type', EXCEL_MIME);
|
||||||
res.setHeader('Content-Length', buffer.length.toString());
|
res.setHeader('Content-Length', buffer.length.toString());
|
||||||
res.status(200).send(buffer);
|
res.status(200).send(buffer);
|
||||||
|
|||||||
Vendored
+2
-2
@@ -123,8 +123,8 @@ function formatTimer(number) {
|
|||||||
* @param {number} number - The number to pad
|
* @param {number} number - The number to pad
|
||||||
* @returns {string} The padded number string
|
* @returns {string} The padded number string
|
||||||
*/
|
*/
|
||||||
function leftPad(number) {
|
function leftPad(val) {
|
||||||
return Math.floor(number).toString().padStart(2, '0');
|
return Math.floor(val).toString().padStart(2, '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export function isRestorePoint(restorePoint: unknown): restorePoint is RestorePo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is.number(restorePoint.startEpoch) && restorePoint.startEpoch !== null) {
|
if (!is.number(restorePoint.startEpoch) && restorePoint.startEpoch !== null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ export async function upload(sheetId: string, options: ImportMap) {
|
|||||||
|
|
||||||
const titleMetadata = Object.values(sheetMetadata)[0];
|
const titleMetadata = Object.values(sheetMetadata)[0];
|
||||||
if (titleMetadata === undefined) {
|
if (titleMetadata === undefined) {
|
||||||
throw new Error(`Sheet read failed: failed to find title row`);
|
throw new Error('Sheet read failed: failed to find title row');
|
||||||
}
|
}
|
||||||
const titleRow = titleMetadata['row'];
|
const titleRow = titleMetadata['row'];
|
||||||
const updateRundown = Array<sheets_v4.Schema$Request>();
|
const updateRundown = Array<sheets_v4.Schema$Request>();
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ describe('parseExcelDate', () => {
|
|||||||
['1899-12-30T07:00:00.000Z', 28800000],
|
['1899-12-30T07:00:00.000Z', 28800000],
|
||||||
['1899-12-30T08:00:10.000Z', 32410000],
|
['1899-12-30T08:00:10.000Z', 32410000],
|
||||||
['1899-12-30T08:30:00.000Z', 34200000],
|
['1899-12-30T08:30:00.000Z', 34200000],
|
||||||
])(`handles %s`, (fromExcel, expected) => {
|
])('handles %s', (fromExcel, expected) => {
|
||||||
expect(parseExcelDate(fromExcel)).toBe(expected);
|
expect(parseExcelDate(fromExcel)).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parses a time string that passes validation', () => {
|
describe('parses a time string that passes validation', () => {
|
||||||
test.each([['10:00:00'], ['10:00'], ['10:00AM'], ['10:00am'], ['10:00PM'], ['10:00pm']])(
|
test.each([['10:00:00'], ['10:00'], ['10:00AM'], ['10:00am'], ['10:00PM'], ['10:00pm']])(
|
||||||
`handles %s`,
|
'handles %s',
|
||||||
(fromExcel) => {
|
(fromExcel) => {
|
||||||
expect(parseExcelDate(fromExcel)).not.toBe(0);
|
expect(parseExcelDate(fromExcel)).not.toBe(0);
|
||||||
},
|
},
|
||||||
@@ -26,13 +26,13 @@ describe('parseExcelDate', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('uses numeric fields as minutes', () => {
|
describe('uses numeric fields as minutes', () => {
|
||||||
test.each([[1], [10], [100]])(`handles numeric fields %s`, (fromExcel) => {
|
test.each([[1], [10], [100]])('handles numeric fields %s', (fromExcel) => {
|
||||||
expect(parseExcelDate(fromExcel)).toBe(fromExcel * MILLIS_PER_MINUTE);
|
expect(parseExcelDate(fromExcel)).toBe(fromExcel * MILLIS_PER_MINUTE);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('returns 0 on other strings', () => {
|
describe('returns 0 on other strings', () => {
|
||||||
test.each([['test'], [''], ['x']])(`handles invalid fields %s`, (fromExcel) => {
|
test.each([['test'], [''], ['x']])('handles invalid fields %s', (fromExcel) => {
|
||||||
expect(parseExcelDate(fromExcel)).toBe(0);
|
expect(parseExcelDate(fromExcel)).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user